【发布时间】:2011-03-08 18:19:45
【问题描述】:
我正在尝试执行基本的 mod_rewrite 清理 URL 技巧,其中 /category/item 重写为 /category/index.php?id=item。在/category 目录中,我的 .htaccess 文件中有这个:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /category/
RewriteRule ^(.+)$ index.php?id=$1 [L]
它将请求发送到index.php 脚本就好了,但是我没有在 id 变量中找到“item”,而是得到了“index.php”。也就是/category/item好像改写成/category/index.php?id=index.php了。
我尝试了无穷无尽的变化,有不同/没有 RewriteBase 和其他更改,但没有任何效果。知道我哪里出错了吗?
【问题讨论】:
-
当你说“在 id 变量中”时,你的意思是
$_GET["id"]吗? -
是的,完全正确。 $_GET 的 print_r 显示
Array ( [id] => index.php )
标签: regex .htaccess mod-rewrite apache2