Suneth Kalhara
Suneth Kalhara

Reputation: 1221

Htaccess remove query string from 301 redirect

I write 301 redirect as below

Redirect 301 /catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79 http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

but when I goes to http://www.thebedroom.com.au/catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79

it redirect http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

........ I need redirect http://www.thebedroom.com.au/manchester/character-bedding.html

Upvotes: 1

Views: 397

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

Remove the query string from your Redirect directive, this is what you have: (make sure to scroll all the way to the right to see the comments)

#                                                                                                                           This question mark right here is why you have a query string in your redirect ---------v
Redirect 301 /catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79 http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

Not really sure why it's working at all, but you need to remove everything AFTER the ?, leaving the ? there. That does have the unsightly side-effect of a stray question mark, but you can get rid of that using mod_rewrite, replacing the Redirect with:

RewriteEngine On
RewriteRule ^catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?$ /manchester/character-bedding.html? [L,R=301]

Upvotes: 1

Related Questions