301重定向无法正常工作

时间:2015-07-29 11:36:23

标签: apache .htaccess redirect

重定向此时我遇到了问题。它没有正确重定向。有没有人知道如何有效地写这个。

redirect 301 /maldives-accommodation/luxury-boutique-hotels/   /hotels-resorts/luxury-boutique-hotels.html
redirect 301 /maldives-accommodation/luxury-star-class-hotels/   /hotels-resorts/luxury-star-class-hotels.html
redirect 301 /maldives-accommodation/maldives-villas/   /hotels-resorts/villas.html
redirect 301 /maldives-accommodation/   /hotels-resorts.html

1 个答案:

答案 0 :(得分:1)

Redirect指令将两个URL路径节点链接在一起,因此您可能希望使用类似RedirectMatch的内容,以便模式之后的所有内容都将被忽略:

RedirectMatch 301 ^/maldives-accommodation/luxury-boutique-hotels/$   /hotels-resorts/luxury-boutique-hotels.html
RedirectMatch 301 ^/maldives-accommodation/luxury-star-class-hotels/$   /hotels-resorts/luxury-star-class-hotels.html
RedirectMatch 301 ^/maldives-accommodation/maldives-villas/$   /hotels-resorts/villas.html
RedirectMatch 301 ^/maldives-accommodation/$   /hotels-resorts.html