URL redirect rewrite using the .htaccess file

Create a 301 redirect for all http requests that are going to the old domain to new domain

If you are wanting to only redirect a specific subdomain, you would do something like this:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomainname.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.olddomainname.com$
  RewriteRule (.*)$ http://www.newdomainname.com/$1 [R=301,L]
</IfModule>

[or]
  
Redirect  301 /olddomainname http://www.newdomainname.com

Tags