Mod_rewrite: Include query string when redirecting
I've got a small problem with mod_rewrite. This is my code:
RewriteEngine on
RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L]
This almost works, if I go to oldsite.com/apage.php, I get redirected to newsite.com/moved.php?q=apage.php.
However, if I go to oldsite.com/apage.php?var=15, I get redirected to newsite.com/moved.php?q=apage.php again. How could I make ol开发者_C百科dsite.com/apage.php?var=15 redirect to newsite.com/moved.php?q=apage.php?var=15 Thanks a lot!Use the QSA flag to get the original requested query automatically appended to the new one:
RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L,QSA]
精彩评论