Skip to content

Instantly share code, notes, and snippets.

@gwokudasam
Forked from sunuazizrahayu/.htaccess
Created October 3, 2019 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwokudasam/157c76f06785e907e51a215330ee8d17 to your computer and use it in GitHub Desktop.
Save gwokudasam/157c76f06785e907e51a215330ee8d17 to your computer and use it in GitHub Desktop.
Force https://www on Codeigniter with .htaccess
RewriteEngine on
#Force WWW
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt|public)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment