Created
February 5, 2022 19:07
-
-
Save michael-sumner/985b6943be370a7c60efbaf13a6ec47a to your computer and use it in GitHub Desktop.
Redirect old domain to new domain and all pages within it, using htaccess file.
This file contains hidden or 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
# BEGIN DOMAIN REDIRECT 301 TOWARDS newdomain.com | |
# ADD THE CODE WITHIN YOUR OLDDOMAIN.COM | |
# MODIFY THE www TO YOUR SPECIFIED SUBDOMAIN | |
# IF YOU ARE USING A NAKED DOMAIN, THEN REMOVE !^www\. | |
# IF YOUR NEWDOMAIN RESOLVES TO ANOTHER SUBDOMAIN | |
# THEN USE THAT NEW SUBDOMAIN INSTEAD OF www. | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com | |
RewriteRule (.*) https://www.newdomain\.com/$1 [R=301,L] | |
# USEFUL FOR: | |
# GOOGLE SEARCH CONSOLE - CHANGE OF ADDRESS | |
# END DOMAIN REDIRECT 301 TOWARDS NEW DOMAIN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment