我的服務器。 htaccess的規則是這樣的:.htaccess規則導致內部服務器錯誤,但它們看起來正確
RewriteEngine On
# first redirect
RewriteCond %{HTTP_HOST} ^www\.testing\.examplewebsite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^testing\.examplewebsite\.co\uk$ [NC]
RewriteRule ^(.*)$ https://testing.examplewebsite.com/$1 [L,R=301]
# second redirect
RewriteCond %{HTTP_HOST} ^www\.test\.examplewebsite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^test\.examplewebsite\.co\uk$ [NC]
RewriteRule ^(.*)$ https://test.examplewebsite.com/$1 [L,R=301]
# Main redirect
RewriteCond %{HTTP_HOST} ^www\.examplewebsite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^examplewebsite\.co\uk$ [NC]
RewriteRule ^(.*)$ https://examplewebsite.com/$1 [L,R=301]
# All subdomains that don't exist redirect
RewriteCond %{HTTP_HOST} ^(.+)\.examplewebsite\.co\.uk$ [NC]
RewriteRule^https://www.examplewebsite.com/ [L,R]
但由於某些原因沒有它會導致服務器內部錯誤,我不知道,如果他們都是100%正確任。像最後一條規則一樣,在起始處也應該使用^(.*)$
,在末尾使用$1
同樣的標誌,不太確定它們是否全部正確。
基本上我試圖讓:
testing.examplewebsite.co.uk
和www.testing.examplewebsite.co.uk
去https://testing.examplewebsite.com
test.examplewebsite.co.uk
和www.test.examplewebsite.co.uk
去https://test.examplewebsite.com
- 其他一些子域像上面
examplewebsite.co.uk
和www.examplewebsite.co.uk
去https://examplewebsite.com
- 使所有使用的域名,例如
stackoverflow.examplewebsite.co.uk
和www.stackoverflow.examplewebsite.co.uk
都被髮送到https://examplewebsite.com
在添加這些規則之前,您的.htaccess工作嗎?你有沒有檢查你的錯誤日誌? –
是的,在我的日誌中沒有錯誤:( – Ryflex
你不能看到正確的apache日誌,它會顯示爲什麼會有500錯誤,很可能是它不能識別'RewriteEngine'刪除第一行RewriteEngine,看看你是否仍然有錯誤 –