2013-11-26 181 views
1

我如何獲得網址重寫以包含www。並不會導致無限循環問題?我有一個URL重定向的問題。我需要確保www。被添加到網址。 我意識到,這已經在.htaccess和一些研究和閱讀後做,我想我需要的代碼是重寫htaccess導致無限循環?

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

這是一個Joomla網站,所以部分隨後是在Joomla SEF節

## Begin - Joomla! core SEF Section. 
# 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
# 
# If the requested path and file is not /index.php and the request 
# has not already been internally rewritten to the index.php script 
RewriteCond %{REQUEST_URI} !^/index\.php 
# and the request is for something within the component folder, 
# or for the site root, or for an extensionless URL, or the 
# requested URL ends with one of the listed extensions 
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] 
# and the requested path and file doesn't directly match a physical file 
RewriteCond %{REQUEST_FILENAME} !-f 
# and the requested path and file doesn't directly match a physical folder 
RewriteCond %{REQUEST_FILENAME} !-d 
# internally rewrite the request to the index.php script 
RewriteRule .* index.php [L] 
# 
## End - Joomla! core SEF Section. 

如果我使用這個Firefox警告我:

The page isn't redirecting properly 

Firefox has detected that the server is redirecting the request for this address in a way that will never complete. 

IE不能找到 頁面如果我刪除重寫線我得到ŧ他的網頁,但URL被重寫爲一個沒有www

我怎麼能強制www。在網址中?

回答

1

似乎重寫規則確實起作用,我發現我的發現是plesk面板有一個強制它們爲www域的選項。或非www。這可能意味着.htaccess和主機中的域設置之間存在衝突。這意味着該網址永遠不會解決。

當我將控制面板更改爲無,重寫規則按預期工作。