【问题标题】:force ssl on entire site with codeigniter htaccess使用 codeigniter htaccess 在整个站点上强制使用 ssl
【发布时间】:2013-03-13 09:56:39
【问题描述】:

我有一个 codeigniter 站点,我希望它始终强制使用 ssl。我正在使用 htaccess 文件删除丑陋的 index.php

这是我现在拥有的 htacces 文件的内容...

 RewriteEngine on
 RewriteCond $1 !^(index\.php|static|robots\.txt)
 RewriteRule ^(.*)$ /index.php/$1 [L]

我必须做些什么才能让它始终使用 ssl?

谢谢!

【问题讨论】:

    标签: php apache .htaccess ssl


    【解决方案1】:

    试试这个:

    RewriteEngine On
    #RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTPS} off
    #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond $1 !^(index\.php|static|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    【讨论】:

    • 当我这样做时,浏览器说该网站有一个重定向循环
    【解决方案2】:

    试试这个:


    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*) index.php?/$1
    

    【讨论】:

      猜你喜欢
      • 2015-07-14
      • 2015-01-08
      • 2013-04-28
      • 2013-09-21
      • 2019-04-12
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多