2016-06-13 79 views
0

過多的重定向我試圖改變一個網站,使得每個頁面重定向到一個特定的頁面上的其他網站上的.htaccess。我已經設法讓非根級別的頁面重定向到沒有問題的新域,但是我似乎試圖從舊網站的根目錄重定向,最終導致了「重定向太多」的問題。這對於優化某個人的網站時非常重要,因爲他們已經從之前的網域進行了更改,因此瞭解這一點非常有用。避免對根級301

我有工作的代碼是這樣的:

Redirect 301 /my_counselling.html newsite.org.uk/ 
Redirect 301 /fees_and_contacts.html newsite.org.uk//?page_id=11 
Redirect 301 /qualifications.html newsite.org.uk/ 
Redirect 301 /resources.html newsite.org.uk/ 
Redirect 301 /abuse.html newsite.org.uk/ 
Redirect 301 /drug_and_alchol.html newsite.org.uk//?page_id=57 
Redirect 301 /lgbt_sexuality.html newsite.org.uk//?page_id=13 
Redirect 301 /dyslexia.html newsite.org.uk//?page_id=8 

但下面試圖匹配根級別全部失敗:

Redirect 301/newsite.org.uk/ 

RewriteRule oldsite.com/ newsite.org.uk [R=301,L,NC] 

RedirectMatch 301 ^/ newsite.org.uk/ 

這是我讀過的建議。

這種感覺應該是很簡單的。如果我能夠將訪問者和殭屍程序轉移到舊網站的根目錄,然後轉到新網站的根目錄,那麼我就完成了。

非常感謝!

回答

0

它看起來像兩個域在同一臺服務器上,在這種情況下,你需要配合對OLDDOMAIN使用RewriteCondition,然後重定向到NEWDOMAIN如果condtion是真實的。

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain.uk$ 
RewriteRule ^(.*)$ http://www.newdomain.uk/$1 [NC,L,R=301]