【发布时间】:2014-01-16 00:14:31
【问题描述】:
我想将我的 nieuws.php?id=$id 重定向到 /nieuws/.html
这是我的 nieuws.php 测试脚本:
<?php
if (isset($_GET["id"])) {
$id = $_GET["id"];
echo "Your ID: $id";
exit();
} else {
echo "No ID";
exit();
}
?>
为此,我在 .htaccess 中有以下脚本。
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^nieuws/([^/]*)\.html$ /nieuws.php?id=$1 [L]
当我打开 http://localhost/nieuws/2.html 时,我得到 No ID
但是,当我将规则更改为:
RewriteRule ^nieuws([^/]*)\.html$ /nieuws.php?id=$1 [L](没有“子目录”)并打开http://localhost/nieuws2.html 它可以工作,我得到您的 ID:2
知道如何添加“子域”吗?
谢谢!
【问题讨论】: