Codeigniter-将http重定向到除一个页面之外的https(Amazon ELB)



我使用的是带有HTTPS的Amazon ELB(ELB将所有流量从443重定向到80),一切都很好。

现在我使用下一个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]

它工作得很好,问题是由于http到https的重定向,亚马逊ELB健康检查失败了,有没有办法将除一个url外的所有流量重定向到https?

(所以我可以在http上使用URL进行健康检查,在https上使用其他URL)

试试这个:

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]

最新更新