Skip to content

Instantly share code, notes, and snippets.

@faisalhmohd
Last active December 23, 2015 17:17
Show Gist options
  • Save faisalhmohd/5c739fb7e4e78c49f442 to your computer and use it in GitHub Desktop.
Save faisalhmohd/5c739fb7e4e78c49f442 to your computer and use it in GitHub Desktop.
Add www to urls and remove index.html/index.htm on urls
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . http://www.%{HTTP_HOST}%1 [R=301,NE,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule . http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]
RewriteEngine On
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