【问题标题】:Redirection http to https not working with AWS EC2 and CodeIgniter将 http 重定向到 https 不适用于 AWS EC2 和 CodeIgniter
【发布时间】:2018-02-01 13:24:19
【问题描述】:

在 AWS EC2 中安装 SSL 后,以下 URL:

... 正在重定向到 https://www.abcd.com 并且运行良好。

但是http://abcd.com 没有被重定向。

我该如何解决这个问题?

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^abcd\.com$ [NC]
RewriteRule ^(.*)$ http://www.abcd.com/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
Options -Indexes

【问题讨论】:

    标签: .htaccess codeigniter amazon-web-services amazon-ec2


    【解决方案1】:

    试试这个:

    RewriteEngine On
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond %{HTTPS} !=on
    RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    

    测试here

    【讨论】:

      猜你喜欢
      • 2018-12-23
      • 1970-01-01
      • 1970-01-01
      • 2015-03-18
      • 2018-01-29
      • 2017-12-13
      • 2018-12-26
      • 2017-02-19
      • 2020-04-29
      相关资源
      最近更新 更多