301 Redirect for All Domains

So you've purchased a ton of domains to park on your main account, but you don't want Google to penalize you for having duplicate content.  And you know that you could go through your .htaccess file creating redirects for each and every one of the domains you're parking.

As your .htaccess file grows and grows, you find yourself asking, "Isn't there an easier way?"  Total Server Solutions says SURE!  Instead of the lines and lines of .htaccess redirects, you could be using, how about these three?

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.YourDesiredDomain.com [NC]
RewriteRule ^(.*)$ http://www.YourDesiredDomain.com/$1 [R=301,L]

What this means in English:

Make sure we've got our rewrite tool enabled
If someone requests a page, and the domain is NOT my preferred domain
Redirect the user to my preferred domain, including the www I've specified here, please, and tell the browser the content should always point here.

So long as you want EVERYTHING to point to the main domain, this will work like a charm.

reviewed 10/14/2016
  • Email, SSL
  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

How do I redirect a page or folder?

I have removed a file from being on the website and would like to forward people who were looking...

301 Redirect from non-www to www -- Without Looping!

So - you want to improve your search engine rankings, and SEO gurus told you that Google might be...

Hotlink protecting image.php and GD images

So you've enabled Cpanel's hotlink protection, but those bandwidth thieves are still attacking...

How to block an IP number

A user is accessing our website and we'd like to block this user as they continue to submit fraud...

Block a country using mod_geoip

Do you have a list of countries that you want to block access to your site?  Have you tried...