简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM