RewriteEngine On .htaccess not working

别说谁变了你拦得住时间么 提交于 2019-12-14 03:52:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!