Skip to content

Instantly share code, notes, and snippets.

@mwender
Created June 17, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwender/8fc1c7629d4ef424d67d to your computer and use it in GitHub Desktop.
Save mwender/8fc1c7629d4ef424d67d to your computer and use it in GitHub Desktop.
Redirect all domain aliases to one with these .htaccess rules.
RewriteEngine On
# If the hostname is NOT www.domain.com
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
# 301 redirect to the same resource on www.domain.com
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment