Skip to content

Instantly share code, notes, and snippets.

@vdite
Created June 27, 2013 21:09
Show Gist options
  • Save vdite/5880425 to your computer and use it in GitHub Desktop.
Save vdite/5880425 to your computer and use it in GitHub Desktop.
Redirect an old domain and all the old sites to a new domain
#this redirects all your old stuff to the main site of the new domain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/ [L,R=301]
#this redirects all your old stuff to the new domain, leaving all deep urls like before
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment