【问题标题】:Codeigniter - redirect http to https except one page (Amazon ELB)Codeigniter - 将 http 重定向到 https,除了一页(Amazon ELB)
【发布时间】:2016-05-03 19:45:52
【问题描述】:

我正在使用带有 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]

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

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

【问题讨论】:

    标签: .htaccess codeigniter amazon-web-services


    【解决方案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]
    

    【讨论】:

      猜你喜欢
      • 2018-08-18
      • 2017-05-10
      • 2011-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-26
      • 2011-10-31
      相关资源
      最近更新 更多