问题
I am trying to make my requests how I handle files like this
/r/login
but have that go to the server like index.php?r=login
This htaccess code that I am using does not seem to be working
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/r/([0-9]+)/$ index.php?r=$1
If anyone could help me out, that would be great!
回答1:
Your code's problem is that you're using leading slash in RewriteRule. If used in .htaccess leading slash is removed by Apache. Change your rule to this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^r/([0-9]+)/?$ /index.php?r=$1 [L,QSA,NC]
来源:https://stackoverflow.com/questions/17006502/rewriteengine-on-htaccess-not-working