使用.htaccess时遇到问题。重写规则如下。
RewriteRule ^user/([a-z]+)/?$ user.php?id=$1
传入网址:http://abhimanyu.localhost.com/user/home/ 它重定向到user.php但我没有得到id。 例如$ id = $ _GET ['id'];
任何想法为什么???
FYI重写日志
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d34d28/subreq]
(1) [perdir
/home/administrator/public_html/abhimanyu/]
pass through
/home/administrator/public_html/abhimanyu/user.php
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d21ce0/initial]
(3) [perdir
/home/administrator/public_html/abhimanyu/]
add path info postfix:
/home/administrator/public_html/abhimanyu/user.php
-> /home/administrator/public_html/abhimanyu/user.php/home
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d21ce0/initial]
(3) [perdir
/home/administrator/public_html/abhimanyu/]
strip per-dir prefix:
/home/administrator/public_html/abhimanyu/user.php/home
-> user.php/home
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d21ce0/initial]
(3) [perdir
/home/administrator/public_html/abhimanyu/]
applying pattern '^user/([a-z]+)/?$'
to uri 'user.php/home'
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d21ce0/initial]
(1) [perdir
/home/administrator/public_html/abhimanyu/]
pass through
/home/administrator/public_html/abhimanyu/user.php
127.0.0.1 - - [08/May/2011:23:38:35 +051800] [abhimanyu.localhost.com/sid#b8b34860][rid#b8d2cd08/subreq]
(1) [perdir
/home/administrator/public_html/abhimanyu/]
pass through
/home/administrator/public_html/abhimanyu/home
答案 0 :(得分:0)
试试这个:
RewriteRule ^user/([a-z]+)$ user.php?id=$1 [NC]
答案 1 :(得分:0)
我无法确定您是否尝试在/user/
之后或/user/home
之后立即捕获字符串。如果您需要捕获两者,请尝试:
^user/([a-z]+)/(.+)$
您可以在使用$1
的用户和使用$2
的第二个字符串后访问第一个字符串。
答案 2 :(得分:0)
尝试停用MultiViews
选项。