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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -