2013-10-25 32 views
0

我有問題重定向確切的文件夾網址。301 redirec文件夾 - 我如何只能重定向確切的網址

Redirect 301 /folder1 /new/test1.html 
Redirect 301 /folder1/sub3folder1 /new/test2.html 

首先代碼的老本行正常,但我有第二線的問題,因爲我不能確切的重定向URL /文件夾1/sub3folder1因爲第一行已經重定向到/new/test1.html和我有結果/新/ test1.html/test2.html,而不是隻/new/test2.com

請幫幫忙,謝謝

回答

0

Redirect指令不支持正則表達式。

呦可以使用RedirectMatch對於這樣的正則表達式的支持:

RedirectMatch 301 ^/folder1/?$ /new/test1.html 
RedirectMatch 301 ^/folder1/sub3folder1/?$ /new/test2.html 
+0

不客氣,讓我知道如果它不工作。 – anubhava

+0

這個工作適合你嗎? – anubhava

1

什麼只是兩行切換? ;)所以Apache將首先嚐試匹配第一行,如果找不到匹配,那麼他會走得更遠。

Redirect 301 /folder1/sub3folder1 /new/test2.html 
Redirect 301 /folder1 /new/test1.html