2016-05-03 34 views
1

我正在使用Amazon ELB和HTTPS(ELB將所有流量從443重定向到80)並且一切正常。Codeigniter - 重定向http至https,除了一頁外(Amazon ELB)

現在我使用的下一個htaccess的代碼從HTTP所有的請求重定向到https:

RewriteEngine On 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 
RewriteCond $1 !^(index\.php|assets) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

及其工作的偉大,問題是,亞馬遜ELB健康檢查失敗,因爲HTTP到HTTPS重定向,有沒有辦法將所有流量重定向到https,只有一個url?

(這樣我就可以使用URL有關HTTP健康檢查和所有其餘的HTTPS)

回答

1

試試這個:

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

RewriteCond %{HTTPS} on 
RewriteCond %{SCRIPT_FILENAME} /specific_controller/specific_method [NC] 
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] 

RewriteCond $1 !^(index\.php|assets) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
相關問題