Reputation: 5668
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!
Upvotes: 0
Views: 2208
Reputation: 3098
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]
Upvotes: 3
Reputation: 1198
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
Upvotes: 0