Created
February 5, 2013 20:03
-
-
Save BernardoSilva/4717188 to your computer and use it in GitHub Desktop.
.htaccess for Codeigniter to avoid index.php and force www. before any URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} !^$ | |
# BEGIN force www before URL | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTPS}s ^on(s)| | |
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# END for www on URL | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ ./index.php/$1 [L] | |
</IfModule> | |
<IfModule !mod_rewrite.c> | |
ErrorDocument 404 index.php | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure it's late to comment, but if you get me the code for .htaccess in how can I force to https and non-www site, that would be a big help here. FYI: the application running with Codeigniter 3.1.9 with Ubuntu 16.4 x64. Thanks in advance!