2016-12-24 69 views
0

我需要重定向加www到www的所有要求,但我也需要每一個重定向將結束在index.php文件重定向WWWNONWWW到使用的.htaccess重寫規則

.htaccess文件代碼

RewriteEngine On 
RewriteBase/
RewriteRule ^(_part) - [F,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule .* index.php?/$0 [PT,L] 

當前URL: http://example.com

預期網址:http://www.example.com

請問,任何人都可以幫助我?

+1

的[重定向非www到在.htaccess WWW]可能的複製(http://stackoverflow.com/questions/12050590/redirect-non-www-to-www -in-htaccess) –

+0

添加預期的輸出,使讀者清楚需要什麼實際的url。 –

回答

0

您可以使用:

RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

RewriteRule ^(_part) - [F,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule .* index.php?/$0 [PT,L]