2017-04-24 127 views
0

問題.htacess從舊域現有的URL,重定向到新的域名

的index.php我有一個新的領域新的TYPO3網站。舊網站的所有重要頁面都指向他們的新對應頁面,我在.htaccess中添加了301個重定向。那些工作很好!

但是有些頁面與舊網站的URL完全相同,我無法爲(無限循環)添加單個重定向。例如/ contact /。當我訪問http://www.example-old.com/contact/時,頁面只是重定向到/index.php。爲什麼?

收藏

  • 所有非www應該被重定向到www 從舊網站(作品)
  • 其他域名應該被重定向到新的(作品)
  • 介紹人應該被重定向到新域中的相同URL,除非手動301重定向到位。 (不工作)

當前設置

這是.htacess片段我的工作:

<IfModule mod_rewrite.c> 

# Enable URL rewriting 

RewriteEngine On 
RewriteBase/

# Point old domain to new domain 

RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^example-new\.com$ [NC] 
RewriteRule ^(.*) http://www.example-new.com/$1 [R=301,L] 

# Point idle domains to new domain 

RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-01.nl [OR] 
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-02.de [OR] 
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-03.eu [OR] 
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-04.net [OR] 
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-05.org 
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] 

</IfModule> 

我想盡組合,我能找到嘗試並得到這個工作。這裏可能會出現什麼問題?

多謝!

回答

0

嘗試刪除前導「/?」而內「:」還從你的HTTP主機條件逃脫最後一個點:

RewriteCond %{HTTP_HOST} ^(www\.)?example-01\.nl$ [OR] 
RewriteCond %{HTTP_HOST} ^(www\.)?example-02\.de$ [OR] 
RewriteCond %{HTTP_HOST} ^(www\.)?example-03\.eu$ [OR] 
RewriteCond %{HTTP_HOST} ^(www\.)?example-04\.net$ [OR] 
RewriteCond %{HTTP_HOST} ^(www\.)?example-05\.org$ 
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] 
+0

感謝您的回覆!我實施了建議的更改,但無法解決我的問題。正常重定向一切工作正常,但任何子頁面重定向仍然轉發到/index.php – Scopestyle

+0

嘗試使用'%{REQUEST_URI}'而不是'/ $ 1' –

+0

在兩次出現'/ $ 1'時添加了這個,沒有運氣: – Scopestyle

0

如果從第一的RewriteCond所有請求老域名將被重定向到新的域名刪除^

如果你想要特定的重定向有優先權,請確保你把它們放在這個之前。

# Point old domain to new domain 

RewriteCond %{HTTP_HOST} example-old\.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^example-new\.com$ [NC] 
RewriteRule ^(.*) http://www.example-new.com/$1 [R=301,L] 
+0

感謝您的建議,我將它添加到了我的代碼中,但它並沒有改變輸出結果。所有現有的「舊」頁面仍然指向/index.php – Scopestyle

+0

您是否有任何其他重寫規則可能導致此問題?本例中沒有/或/index.php的引用,請查找並檢查樹中所有可能影響url重寫的.htacces文件。 – Thakkie

相關問題