目前我使用以下代码重写我的url:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
url 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