开发者

ID not being passed in RewriteRule

I am facing an issue while using .htaccess.The Re write rule is as follows.

RewriteRule ^user/([a-z]+)/?$ user.php?id=$1

incoming url : http://abhimanyu.localhost.com/user/home/ its redirecting to user.php but i am not getting the id. e.g $id= $_GET['id'];

any idea why???

FYI the re write logs

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 '开发者_StackOverflow社区^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


Try this:

RewriteRule ^user/([a-z]+)$ user.php?id=$1 [NC]


I can't tell if you're trying to capture the string immediately after /user/ or after /user/home. If you need to capture both, try this:

^user/([a-z]+)/(.+)$

You can access the first string after user with $1 and the second string with $2.


Try disabling the MultiViews option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜