开发者

301 Redirect and query strings

开发者 https://www.devze.com 2022-12-23 17:28 出处:网络
I am looking to create a 301 redirect based purely on a query string see b OLD URL: olddomain.com/?pc=/product/9999

I am looking to create a 301 redirect based purely on a query string see b

OLD URL: olddomain.com/?pc=/product/9999
New URL: newurl.php?var=yup

My normal way of doing this would be

redirect 301 pc=/product/9999 newurl.php?var=yup

But t开发者_开发知识库his time I am trying to match a URL that that only contains the domain and a query string...

What is the best way of doing this?

Thanks


I used the following to solve my problems:

RewriteCond %{QUERY_STRING} ^pc=/product/9999
RewriteRule (.*) http://www.newdomain.com/index.php?var=yup [L,R=301]


I used the following to solve my problems

RewriteCond %{QUERY_STRING} ^art_id=33128 
RewriteRule ^(.*)$ http://www.yourdomain.com/pages/33128?  [R=301,L] 

To remove unwanted query string after rewriting, use '?' after Rewrite Rule

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号