Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active February 3, 2018 03:08
Show Gist options
  • Save davidsword/911630c964456fca18a0fcdb3b0ba0b2 to your computer and use it in GitHub Desktop.
Save davidsword/911630c964456fca18a0fcdb3b0ba0b2 to your computer and use it in GitHub Desktop.
# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com/$
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com$
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment