2014-03-05 41 views
0

我實際上想將舊網站網址重定向到新網站網址。301使用.htaccess重定向不能用於多個參數

我已經1個重定向例如

http://www.abc-old.com/test to http://www.abc-new.com/test123 

但問題妥善

工作是當我有多個塊或參數它不會工作,我

我想重定向

http://www.abc-old.com/test1/test2 to http://www.abc-new.com/test1 

但它重定向像

http://www.abc-old.com/test1/test2 to http://www.abc-new.com/test1/test2 
下面

是我同

Redirect 301 /test1/test2 http://www.abc-new.com/test1 

代碼請幫我弄清楚這個

回答

0

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

RedirectMatch 301 "/test1/test2(/.*)?$ http://www.abc-new.com/test1$1 
+0

沒有工作的人:( –

+0

這些類型的意見從來沒有幫助。沒有什麼網址您是否嘗試過?是否導致404?是否存在現有規則?是否發佈有問題 – anubhava

+0

謝謝解決。 –

0

枝有些我如何解決它,但仍然迷惑,爲什麼這件事情happned?

,比如我有3

http://www.old.com/test1/ 
http://www.old.com/test1/test2 
http://www.old.com/test1/test2/test3 

我已創建301網址在.htaccess重定向像

Redirect 301 /test1/ http://www.new.com/test1 
Redirect 301 /test1/test2/ http://www.new.com/test2 
Redirect 301 /test1/test2/test3 http://www.new.com/test3 
在這種情況下

,而我是請求

http://www.old.com/test1/ is redirected to http://www.new.com/test1 

http://www.old.com/test1/test2 is redirected to http://www.new.com/test1/test2/ 
在這種情況下,而服務器上執行的.htaccess,第一,而不是我的第二個URL重定向

是工作和額外的參數傳遞test2的,因此新的重定向是http://www.new.com/test1/test2

我有這樣

寫代碼
Redirect 301 /test1/test2/test3 http://www.new.com/test3 
Redirect 301 /test1/test2/ http://www.new.com/test2 
Redirect 301 /test1/ http://www.new.com/test1 

它開始工作。我真的不明白爲什麼我的第一個代碼不能正常工作,我已經使用了wordpress CMS,是否有任何需要的配置?