开发者

.htaccess mod_rewrite + $_GET not working

I have the following mod_rewrite line (it's the only line in the .htaccess file). It works when I change the first name to something other than login, but for some reason fails to pass the $_GET['initials'] when it's the same name as the actual script. Is it somehow overwriting its own rewrite?

RewriteRule ^login/([a-z]{1,5}) login.php?initials=$1 [L]

Edit:

Looking at $_SERVER, this is the page that PHP ends up loading:

开发者_开发问答
'PHP_SELF' => string '/admin/login.php/abc' (length=19)

where 'abc' is the intitials provided. So it's dropping the query string completely and trying to load that page, which somehow loads login.php and not a 404 even though the /abc directory doesn't exist?


Try using this instead:

RewriteEngine On
RewriteBase /SUBDIRECTORY_NAME_HERE/
RewriteRule ^login/([^/]*)/$ /login.php?initials=$1 [L]

May help also if you add the sub directory in front of login.php.

RewriteRule ^login/([^/]*)/$ /SUBDIRECTORY_NAME_HERE/login.php?initials=$1 [L]


It is in the comments above but it does not really tell you what to do. Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteBase /SUBDIRECTORY_NAME_HERE/ RewriteRule ^login/([^/]*)/$ /login.php?initials=$1 [L]

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜