HTACCESS - Redirect Secondary Domains to Primary Domain


/ Published in: Apache
Save to your folder(s)

This is if you have multiple domains pointed to the same directory on a server.


Copy this code and paste it in your HTML
  1. Options +FollowSymLinks
  2. RewriteEngine On
  3. RewriteCond %{HTTP_HOST} ^secondarydomain1.com$ [OR]
  4. RewriteCond %{HTTP_HOST} ^www.secondarydomain1.com$
  5. RewriteRule (.*)$ http://www.primarydomain.com/$1 [R=301,L]
  6.  
  7. RewriteCond %{HTTP_HOST} ^secondarydomain2.com$ [OR]
  8. RewriteCond %{HTTP_HOST} ^www.secondarydomain2.com$
  9. RewriteRule (.*)$ http://www.primarydomain.com/$1 [R=301,L]

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.