Forum Moderators: phranque

Message Too Old, No Replies

Strip parms from URL and 301

         

Karma

8:31 am on Jul 1, 2011 (gmt 0)

10+ Year Member



Hi,

I'm finding multiple instances in Google WMT reports where my URLs are having parameters added, such as:

mydomain.tld/widget/blue/?pagewanted=all

Without going in to why these parameters are there, is there any way I can easily 301 these back to the correct URL?

So...

mydomain.tld/widget/blue/?pagewanted=all

will 301 back to...

mydomain.tld/widget/blue/

[edited by: Karma at 8:55 am (utc) on Jul 1, 2011]

lucy24

8:39 am on Jul 1, 2011 (gmt 0)

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



Could you do that again using example.com? When I read the obfuscated address off the bottom of my browser window, it says
../widget/blue/<b>?pagewanted=all</b>
and it would be nice to know if those are your own bold tags or google's.

Yes, it's trivial to make a RewriteRule that simply chops off the query string if it isn't supposed to be there. A final question mark on the target side means "get rid of the query". (On the input side it's a standard RegEx question mark. And inside [brackets] it's a literal question mark. I hope someone is paying it overtime.)

Karma

8:55 am on Jul 1, 2011 (gmt 0)

10+ Year Member



Fixed :)

Karma

6:16 pm on Jul 1, 2011 (gmt 0)

10+ Year Member



How would I go about doing this? Simple as possible please

g1smd

8:39 am on Jul 2, 2011 (gmt 0)

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



Let's see your two lines of mod_rewrite code for discussion...

I assume you'll have a RewriteCond testing THE_REQUEST and a RewriteRule with [R=301,L] flags.