user1039856
user1039856

Reputation: 1

htaccess not redirecting because of '?'

I'm having a problem with my htaccess, we've moved a website and they're old website had a lot of duplicate pages that had a ?cat_id=88 etc... on them, I'm trying to redirect the page but it's not working, I've put the redirect code below, I'm already redirection the mantra.html to the /Mantra but the version with the ?cat_id=79 isn't redirecting, it's just ignoring everything after the ?

Redirect 301 /mantra.html?cat_id=79 http://www.website.co.uk/Mantra

Upvotes: 0

Views: 56

Answers (1)

Gerben
Gerben

Reputation: 16825

Redirect only accepts paths, not paths with querystring. You could use mod_rewrite

RewriteEngine on
RewriteCond %{QUERY_STRING} ^cat_id=79$
RewriteRule ^mantra\.html$ /Mantra? [R=302,L]

change 302 to 301 once you get it working (301 are aggressively cached by browsers and make debugging a nightmare).

EDIT added a ? at the end to remove any querystring. Apache removes the ? if there is no other data in the querystring, so the end user will never see it.

Upvotes: 1

Related Questions