问题
I need the following request :
http://somesite.com/home.php?action=page&page_id=9
to trigger a 301 redirect to :
http://somesite.com/a-new-page
Here's what I'm using but it isn't working.
RewriteCond %{QUERY_STRING} ^page_id=9$ [NC]
RewriteRule ^home\.php$ http://somesite.com/a-new-page? [L,R=301]
Any ideas?
回答1:
If the QUERY_STRING will always be the same you need to match it like this:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^action=page&page_id=9$ [NC]
RewriteRule ^home.php$ http://somesite.com/a-new-page? [L,R=301]
Hope this helps.
来源:https://stackoverflow.com/questions/7277154/301-redirect-of-old-url-with-parameters-to-a-path-without-parametes