【问题标题】: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