Skip to content

Instantly share code, notes, and snippets.

@earvinpiamonte
Created September 1, 2019 04:55
Show Gist options
  • Save earvinpiamonte/af447b465d263277e54d80627c625a00 to your computer and use it in GitHub Desktop.
Save earvinpiamonte/af447b465d263277e54d80627c625a00 to your computer and use it in GitHub Desktop.
Codeigniter .htaccess - force HTTPS
RewriteEngine On
# start force http www (optional)
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# end force http www (optional)
# start force https
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# end force https
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment