Forum Moderators: phranque

Message Too Old, No Replies

Skip the certain parameter in mod rewrite rules.

         

keziah

10:37 pm on Nov 9, 2011 (gmt 0)

10+ Year Member



Please help me with mod_rewrite rules.
I need to skip every occasion of parameter '&lang=' and any of its value (en, it...) in URL and redirect 301 as it is without this parameter(s).

Examples:
I want to all of these URL's examples:
www.my_domain.com?id=3343&lang=de
www.my_domain.com?id=3343&lang=it
www.my_domain.com?lang=en&id=3343
www.my_domain.com?id=3343&lang=en&lang=it

redirect me to the same URL:
www.my_domain.com?id=3343

How can i do this with mod_rewrite rule?
Thanks!

wilderness

10:50 pm on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The SEARCH link is located on the second line of the Webmaster World header near the very top of this page, and every other page at Webmaster World.

Search for "string" and "QSA"

lucy24

11:46 pm on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



But this is the opposite of a QSA, isn't it? You're deleting one category of query while putting back everything else.

The question is whether you even need to do it. Where you have query strings, you have things happening behind the scenes. If the behind-the-scenes code is already ignoring the "lang" query, why bother with the redirect? If it's a Duplicate Content worry, tell GWT to ignore all "lang" parameters. And clean up your site code to make sure it isn't getting attached in any existing pages.

Does your example show all possible configurations?

lang= after other queries
lang= before other queries
lang= more than once, but all grouped together

If there is any possibility of the "lang" query happening more than once, separated by other queries, your RewriteCond goes to a whole new level of complexity. Same if it could come between other queries. Does any other query potentially start in l?

Or is it the other way around? Does the query string consist of one or more "lang=" and just one "id=", and all you want to keep is the "id=" part? Once you're read up on Query Strings, you will see that it's a lot easier if you approach it from that side.

keziah

1:58 pm on Nov 10, 2011 (gmt 0)

10+ Year Member



lucy24,
You have right! My worry was a Duplicate content. As you suggest, solution is to tell Google to ignore all "lang" parameters". I did not know that it possible.
Thanks a lot !