简体   繁体   中英

htaccess redirect full url (including query string)

Currently I use this code for rewriting my urls:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 

The url http://www.website.com/test/ gets redirected to index.php?url=test/ . I also would like that http://www.website.com/test.php?page=123 gets redirected to index.php?url=test.php%3Fpage%3D123 so I can use this for dynamically detecting old redirects. How could this be achieved?

Use %{QUERY_STRING}

RewriteRule ^(.*)$ index.php?url=$1%{QUERY_STRING}

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM