Last active
August 29, 2015 14:13
-
-
Save schilke/79b0cb87b3bb93a7c309 to your computer and use it in GitHub Desktop.
Redirect rules on change of domain name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect all requests from olddomain.com to www.newdomain.com | |
# 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 .* http://www.newdomain.com%{REQUEST_URI} [R=301,L] | |
# Redirect end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was asked in the LinkedIn group Wordpress Experts
https://www.linkedin.com/groups/Need-help-301-redirects-1482937.S.5962641276233859073?view=&item=5962641276233859073