Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Redirect rules on change of domain name
# Redirect all requests from to
# tell the server to activate mod_rewrite
RewriteEngine On
# What's the redirect base (i.e. root or subdirectory)
RewriteBase /
# Either check if the request goes to the old domain
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
# Just in case you want to redirect any subdomain as well
# uncomment the following line
# RewriteCond %{HTTP_HOST} ^(.*\.)?olddomain\.com$ [NC]
# or - as a more general alternative - check if the request does
# _not_ go to the _new_ domain (just comment/uncomment the condition)
# RewriteCond %{HTTP_HOST} !^(www\.)?newdomain\.com$ [NC]
RewriteRule .*{REQUEST_URI} [R=301,L]
# Redirect end

This comment has been minimized.

Copy link
Owner Author

@schilke schilke commented Jan 20, 2015

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