2016-11-21 40 views
0

我已經有一對夫婦的規則設置,如爲什麼我的重定向301不起作用?

RewriteCond %{HTTP_HOST} ^www.pipcanadaltd\.com$ [NC] 
RewriteRule .?$ http://ca.pipglobal.com%{REQUEST_URI} [R=301,L] 

而且我也有幾個PHP頁面如重寫:

RewriteRule ^products/eye-protection-experts/$ prod-expert-eyewear.php [NC,L] 

出於某種原因,當我去創造一個更簡單的301重定向,它不工作。這裏是我有:

RewriteRule ^products/construction-channel-experts/$ ^products/construction-safety-solutions/ [R=301] 

我真的很困惑,爲什麼這是行不通的。

回答

0

您可以使用此規則301重定向:

RewriteRule ^products/construction-channel-experts/?$ /products/construction-safety-solutions/ [R=301,L,NC] 

注意^用於在正則表達式匹配的開始位置,它只能在模式是左手邊的使用。

您應該在內部重寫規則之前保留重定向規則。

+0

好吧我試過這個,但我仍然得到一個404,所以可能有配置問題。 – timrosenthal

+0

試試:'RewriteRule^products/construction-channel-experts /?$ products/construction-safety-solutions/[R = 301,L,NC]'(假設你有上面定義的'RewriteBase') – anubhava

相關問題