Scott Eldo
Scott Eldo

Reputation: 473

301 Redirect not working on particular URL

I have a redirect rule set up as below

Redirect /Products.aspx?Category_ID=15 https://www.trainerbubble.com/free-training-resources/

However, when going to the address it attaches itself to an existing page /training-products and results in this

https://www.trainerbubble.com/training-products/?Category_ID=15

How can I force the original redirect and make it stop thinking its part of the /training-products page?

Upvotes: 1

Views: 12

Answers (1)

anubhava
anubhava

Reputation: 784938

You cannot match query string in Redirect directive. Use mod_rewrite rules instead:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^Category_ID=15$ [NC]
RewriteRule ^Products\.aspx$ https://www.trainerbubble.com/free-training-resources/? [L,NC,R=301]

? at the end of target URL is to strip off previous query string.

Upvotes: 1

Related Questions