2014-06-29 45 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] 
相關問題