繁体   English   中英

htaccess重定向完整网址(包括查询字符串)

[英]htaccess redirect full url (including query string)

目前,我使用以下代码重写我的网址:

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

网址http://www.website.com/test/重定向到index.php?url=test/ 我还希望将http://www.website.com/test.php?page=123重定向到index.php?url=test.php%3Fpage%3D123以便我可以使用它来动态检测旧的重定向。 如何做到这一点?

使用%{QUERY_STRING}

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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