2015-06-03 22 views
0

是否有可能創建一個重寫規則都向上移動類別:重寫301條重定向規則,一切都向上移動類別

例如:

來自:

/類別/second-category/product-name.html

/category/second-category/third-category/product-name.html

到:

/second-category/product-name.html

/second-category/third-category/product-name.html

我已經改變了結構,需要添加501重定向,只知道如何做每個人,不喜歡做200+。

回答

0

您可以使用此規則在根的.htaccess:

RedirectMatch 301 ^/(?:cat1|cat2|cat5)/(.+?\.html)$ /$1 
+0

我們可以應用規則,以便它僅適用於某些類別的網站上有負荷的鏈接等。所以也許/根/(做了一些魔法)/root2 /(更多魔術) – James

+0

是的,請參閱更新的答案。它現在只適用於'cat1'或'cat2'或'cat5'。 – anubhava

+1

啊超,我會看看,看看它是否做到了。 – James