How to redirect (via htaccess 301) multiple TLD's to one website?

Hi all,

I was wondering how I could best do the following redirect:

I have several TLD’s (www.mycompany.net / [URL=“http://www.mycompany.org”]www.mycompany.org / [URL=“http://www.mycompany.eu”]www.mycompany.eu / [URL=“http://www.mycompany.info”]www.mycompany.info / …) and I want to redirect them all (using a htaccess 301) to an existing website [URL=“http://www.mycompany.com”]www.mycompany.com.

I know I have to do this with a .htaccess (301 redirect) file, but what I don’t know is how to set the .htaccess file up in Plesk.

Do I:[LIST=1]
[]create one hosting for www.mycompany.com and put a .htaccess file in the root with the redirects to all other TLD’s.
[
]create multiple hostings for all TLD’s en create multiple .htaccess files for every hosted TLD.
[*]something else.[/LIST]Thanks for any feedback.

Mike

Repeat as necessary. Although I suspect there is a shorter way to write that for multiple domains.


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\\.)?old-domain\\.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]

TF,

You provided a LOT of information but NOT the critical point: WHERE (physically) are all the domains pointing to? If they’re all in the same physical DocumentRoot, your problem becomes simple (and Plesk has NOTHING to do with the solution):

# stymiee was very close!
# .htaccess in SHARED DocumentRoot
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\\.)?mydomain\\.com$ [NC]
RewriteRule .?$ http://www.mydomain.com%{REQUEST_URI} [R=301,L]

… which will redirect EVERY request make to EVERY domain located in this DocumentRoot to www.mydomain.com. Any query string will be sent along separately (unchanged) but, as with every change in domain (and the PERMANENT redirection), the www.mydomain.com will be displayed.

Regards,

DK

stymiee, dklynn, thanks for answering.

dklynn, the nameservers of all domains are pointing to our webserver. (ns1.companyname.be & ns2.companyname.be)
I wonder how can I point all domains to the document root of the main website?

TF,

That’s normally a function of Plesk or CPanel or … to add/change the contents of the httpd.conf’s VirtualHost section when you add or modify a domain’s pointer. SOMEWHERE (as above), you will find where to change the DocumentRoot (physical directory pointer for the domain’s root directory) and that’s where you can force your domains to share (or not to share).

Regards,

DK