Please help with this mod_rewrite issue
This current system in place needs to allow periods (.
) optionally inside of the rewrite condition.
For example: /john.doe
should work, since we allow periods in our user names.
However when I add .
or \\.
or [.]
to the following rewrite rule, it either gets stuck in an endless loop, having to restart apache2. Amazingly, the behaviour has changed and I am not sure why. Now it just appends the new string to the existing URL.
For example: /john.doe
will become /john.doe/?pg=user&username=john.doe
RewriteRule ^/([a-z0-9_]+)$ /?pg=user&username=$1 [NC,PT]
I am going crazy trying to fix this开发者_Python百科, please help!
This should work (I'm saying "should" as I do not know how your whole system is set up and what other redirects etc are in place -- I see you are using PT
flag (maybe you are using aliases)):
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^([a-z0-9_\.]+)$ /index.php?pg=user&username=$1 [NC,QSA,L]
OR
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9_\.]+)$ /index.php?pg=user&username=$1 [NC,QSA,L]
I have specified the script file directly -- it's much more easier to write a rule if you know how it works behind.
精彩评论