Multiple TLD's - .htaccess 301 Redirect

Refresh

December 2018

Views

753 time

4

I have an Ubuntu Server that runs Apache w/ Virtual Hosts. I run a website with the primary domain as "mydomain.com" and it's located in /var/www/mydomain.com.

Assuming I own multiple domain names (each with a different tld), what's the best way to make sure they all point to "mydomain.com" (the primary site).

In other words, is it best to create an .htaccess file in /var/www that has multiple 301 redirects for sites like "mydomain.net" and "mydomain.org" that point to "mydomain.com"?

1 answers

5

Попробуйте что-то вроде этого:

<VirtualHost 1.2.3.4:80>
    DocumentRoot /var/www/mydomain.com
    ServerName mydomain.org
    ServerAlias mydomain.net mydomain.info mydomain.me
    RedirectPermanent / http://www.mydomain.com/
</VirtualHost>