2014-09-30 43 views
1

我现在有一个网站,是由重定向 -创建多个的.htaccess重定向

#-- Redirect http://www.mywebsite.com/en/index.php ---> http://www.mywebsite.com/ 
#Redirects 
RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC] 
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L] 

我需要添加另一个条件是从mywebsite.com重定向--->http://www.mywebsite.com/

基本上我需要添加一个语句来重定向非www用户强制它们进入wwww。

如何在没有条件和规则的情况下做到这一点?

任何帮助表示赞赏

回答

0
RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com 
RewriteRule ^(.*)$ http://www.mywebsite.com$1 [L] 
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC] 
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L] 

有可能不提mywebsite.com可言,只是为了检查起始www和使用反向引用域(没有检查规则)。

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\.(.*)$ 
RewriteRule ^(.*)$ http://www.%1$1 [L] 
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC] 
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]