301 Redirect of old url with parameters to a path without parametes

不问归期 提交于 2020-01-06 04:45:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!