问题
How can I rewrite the following:
http://www.mydomain.com/my-page.html to http://www.mydomain.com/my-page.html?type=1
Tried the following without any luck:
RewriteRule /car-covers.html$ /car-covers.html?type=$1 [R=301,L]
RewriteRule ^car-covers.html$ car-covers.html?type=$1 [QSA,L]
回答1:
RewriteRule ^html page/([^/\.]+)?$ index.php?action=search_refine&type=$1 [L]
回答2:
With RewriteRule
you can only test the URI path but not the query. You need to use RewriteCond
to do so, for example:
RewriteCond %{QUERY} !(^|&)type=
RewriteRule ^car-covers\.html$ car-covers.html?type=$1 [QSA,L]
This will add the parameter type to the query and do an internal rewrite. If you want an external redirect, add the R flag.
来源:https://stackoverflow.com/questions/3887496/append-query-string-via-apache-rewrite-rule