2014-06-29 41 views
0

我试图强制使用运行表达式引擎的网站的.htaccess进行HTTPS。 截至目前,您可以使用https://访问该网站,但是当我添加这些规则时,它会显示重定向循环。在表达式引擎重定向循环上强制HTTPS

RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

RewriteCond %{SERVER_PORT} !^443$ 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L] 

,也看中了这一个

RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 

,我也试着重新安排所有的规则对他们每个人如此我很确定它有什么关系条件匹配时,他们不应该。

我也看到了有关负载平衡器重定向的事情有些事情从这里专柜的.htaccess : .htaccess redirect loop when trying to add forced HTTPS rule (Amazon Elastic Beanstalk)这里:https://serverfault.com/questions/283525/force-ssl-on-one-page-via-htaccess-without-looping

我觉得我的客户正在使用INMOTION托管,但我用不上到负载均衡器设置,所以我想确保这是问题。

这里是整个htaccess。我删除了一些默认的表达式引擎,但是在我这样做之前它也没有工作。

<IfModule mod_rewrite.c> 
# Enable Rewrite Engine 
# ------------------------------ 
RewriteEngine On 
RewriteBase/

# RewriteCond %{HTTPS} off 
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

# RewriteCond %{HTTP:X-Forwarded-Proto} !https 
# RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 

# Redirect index.php Requests 
# ------------------------------ 
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] 
RewriteCond %{THE_REQUEST} ^GET 
RewriteRule ^index\.php(.+) $1 [R=301,L] 

# Standard ExpressionEngine Rewrite 
# ------------------------------ 
RewriteCond $1 !\.(css|js|images|gif|jpe?g|png) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

(我有他们禁用,因为该网站是活的)

回答

1

您可能会更好张贴在EE Stack Overflow site。或者有一个搜索就可以了,因为这涉及到https一些答案和的.htaccess

这里有一个帖子我回复了以前一个答案,你可能会想尝试: https://expressionengine.stackexchange.com/questions/7601/adding-a-htaccess-redirect-to-https-that-plays-nicely-with-existing-ee-htacces/7659#7659

如果这个条件不工作:

RewriteCond %{SERVER_PORT} !^443$ 

试试这个:

RewriteCond %{HTTPS} !=on 

取而代之的是一个:

RewriteCond %{HTTPS} off 
1

我有同样的情况,这里就是刚刚为我工作与EE3网站:

#non-www to www 
RewriteCond %{HTTP_HOST} !^www\.domainname\.co.uk$ 
RewriteRule (.*) https://www.domainname.co.uk/$1 [R=301,L] 

# Force HTTPS 
RewriteCond %{HTTPS} !=on 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

# Removes index.php from ExpressionEngine URLs 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
RewriteCond %{REQUEST_URI} !/system/.* [NC] 
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 
相关问题