Skip to content

Instantly share code, notes, and snippets.

@jai-o
Created April 5, 2012 18:47
Show Gist options
  • Save jai-o/2313195 to your computer and use it in GitHub Desktop.
Save jai-o/2313195 to your computer and use it in GitHub Desktop.
Works! Removes Index.php, Force HTTPS, removes www
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
# Depends on your web host and setup, check with your web host specific settings
RewriteCond %{ENV:SECURE_REDIRECT} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
# Make www to non-www
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
@jameswbutts
Copy link

Do you need the [OR] on line 17? Looks like it's just the one conditional.

@jai-o
Copy link
Author

jai-o commented Apr 5, 2012

Thanks James! That did it!

@jai-o
Copy link
Author

jai-o commented Apr 10, 2012

Note for forcing HTTPS, check with your specific web host as their configuration may require different RewriteCond

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment