简体   繁体   中英

.htacess redirect 301 doesn't work properly

I have issue to redirect 301 URLs,

I want to redirect from fr.example.com/fr to www.example.com/fr-ch the rest of the URL doesnt have always same structure but htaccess redirect to same structure, exemple:

RewriteCond %{HTTP_HOST} ^fr\. [NC]
Redirect 301    /fr   https://www.example.com/fr-ch         
Redirect 301    /fr/coffee/arabica-robusta  https://www.example.com/fr-ch/ccc/arabica-robusta

what I get as result is redirect to https://www.example.com/fr-ch/coffee/arabica-robusta

and not to

https://www.example.com/fr-ch/ccc/arabica-robusta

Am I missing something ??

You need to redirect EXACTLY /fr, so you need to add ^ in the beginning and $ at the end.

So this should work :

Redirect 301    ^/fr$   https://www.example.com/fr-ch         

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