2016-12-28 87 views
0

我已經嘗試下面的代碼重定向非WWW到WWW URL在WordPress的但它不工作。.htacces重定向不工作非WWW URL到WWW URL

請檢查以下代碼是否正確?

<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain.ie[nc] 
RewriteRule ^(.*)$ http://www.domain.ie/$1 [r=301,nc] 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

</IfModule> 
+0

待辦事項你有mod_rewrite安裝?你看到日誌中有任何錯誤嗎? – Dekel

+0

爲什麼不工作?你收到一些錯誤信息嗎? –

+0

@KoenHollander 500內部服務器錯誤 –

回答

1

正確的.htaccess規則應該是:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC] 
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301] 

請記住,WordPress的已安裝在.htaccess文件自己重寫規則,不要刪除它們(它們被放在註釋行# BEGIN WordPress# END WordPress之間)