简体   繁体   English

使用codeigniter htaccess在整个站点上强制ssl

[英]force ssl on entire site with codeigniter htaccess

I have a codeigniter site, and I want it to force ssl all the time. 我有一个codeigniter网站,并且我希望它一直强制ssl。 I'm using the htaccess file to remove the ugly index.php 我正在使用htaccess文件删除丑陋的index.php

this is the contents of the htacces file that I have now... 这是我现在拥有的htacces文件的内容...

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

What do I have to do to get it to always use ssl? 我要怎么做才能始终使用ssl?

Thanks! 谢谢!

Try this: 尝试这个:

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]

Try This: 尝试这个:


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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM