Skip to content

Instantly share code, notes, and snippets.

@hatzipanis
Created May 1, 2017 19:24
Show Gist options
  • Save hatzipanis/c0b3648bf0f56c3cbc84fe4ca5090be9 to your computer and use it in GitHub Desktop.
Save hatzipanis/c0b3648bf0f56c3cbc84fe4ca5090be9 to your computer and use it in GitHub Desktop.
www to non-www redirect with Craft
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment