Skip to content

Instantly share code, notes, and snippets.

@samarpanda
Last active August 29, 2015 14:16
Show Gist options
  • Save samarpanda/4c35fd0a5fee378bb985 to your computer and use it in GitHub Desktop.
Save samarpanda/4c35fd0a5fee378bb985 to your computer and use it in GitHub Desktop.
Update htaccess to redirect www.domain.com to domain.com

Required htaccess changes for http and https

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]

References:

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