简体   繁体   中英

force ssl on entire site with codeigniter htaccess

I have a codeigniter site, and I want it to force ssl all the time. I'm using the htaccess file to remove the ugly index.php

this is the contents of the htacces file that I have now...

 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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