php - How to do a basic URL rewrite with mod_rewrite -
i don't understand why when use this:
#rewriterule ^/?r/(.*)$ /index.php?n=$1 [l]
to rewrite mysite.com/r/somewhat
mysite.com/index.php?r=somewhat
site work.
but if use this:
#rewriterule ^/?(.*)$ /index.php?name=$1 [l]
to rewrite mysite.com/somewhat
mysite.com/index.php?r=somewhat
, site stop working.
i don't understand why. can me?
how can rewrite mysite.com/somewhat
mysite.com/index.php?r=somewhat
?
your 2nd rule cause infinite looping since target uri /index.php?r=somewhat
matches .*
. causes 500 internal server error.
to fix need avoid rewriting files , directories using rewritecond
this:
rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^/?(.+)$ /index.php?r=$1 [l,qsa]
Comments
Post a Comment