Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Last active October 23, 2019 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eksiscloud/4f3d47fdcbd9ed6215de2be890b28639 to your computer and use it in GitHub Desktop.
Save eksiscloud/4f3d47fdcbd9ed6215de2be890b28639 to your computer and use it in GitHub Desktop.
Redirect a site to new domain
# Rewriting on
RewriteEngine on
# redirect to same page in the new site as where a user was in the old site
RewriteBase /
RewriteCond %{SERVER_NAME} =old-domain.com [OR]
RewriteCond %{SERVER_NAME} =new-domain.com
RewriteRule ^ http://new.domain.com%{REQUEST_URI} [END,NE,R=301]
# you can use IfModule structure too.
# You can put it in vhost conf or in .htaccess
#<IfModule mod_rewrite.c>
#RewriteCond %{SERVER_NAME} =old-domain.com [OR]
#RewriteCond %{SERVER_NAME} =new-domain.com
#RewriteRule ^ http://new.domain.com%{REQUEST_URI} [END,NE,R=301]
#</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment