开发者

301 Redirect for URL's with Query string

I want to do a 301 redirect for all urls with a query string to the base url (without the query string).

For example:

  1. http://www.mysite.com/directory/abcbd.html?q1=23&q2=89 should be redirected to http://www.mysite.com/directory/abcbd.html

    1. http://www.mysite.com/directorynew/file3.html?q1=213&q2=389&q3=ttim should be redirected to http://www.mysite.com/directorynew/file3.html

As show开发者_开发知识库n in the above examples "q1=" will ALWAYS appear in the beginning in the urls in question. The next set of urls could vary. So is there something like: RewriteCond %{query_string} "q1=.*" - not good at these things!

What entries do I need to enter in the .htaccess file?

Thanks, Sameer


I'd have done it with this rule:

RewriteRule ^(.*)\?.*  $1  [L,R=301]


Actually I got it done using the wp_redirect plugin.

source: /(.)/(.).html(.)\?dontneedthisstring=(.) target: /$1/$2.html

This cleans it up.

Here "dontneedthisstring" was the uniq string i was trying to get rid of.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜