Search left

Plesk Linux Domain Alias 301 HTTP Redirect



The problem: A Plesk client has one or more domain aliases defined in Plesk Linux. In this article we’ll suppose that the main domain is my-domain.com, having my-domain.net as a domain alias.

In this case, the domain alias my-domain.net will appear as separate site to search engines (Google, Yahoo, MSN and so on). This situation can create duplication issues and can affect the PageRank of the main site.

The solution: We’ll use an Apache .htaccess file to create a Search Engine Friendly 301 redirect from the domain alias (my-domain.net) to the main domain (my-domain.com).

Open (or create if it doesn’t exist) the Apache .htaccess file from the root folder (usualy /httpdocs) and add on top of it:

RewriteEngine on

# 301 Redirect requests from my-domain.net to my-domain.com
RewriteCond %{HTTP_HOST} !^(www\.)my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [L,R=301]

The RewriteCond line checks to see if the HTTP_HOST is NOT my-domain.com. If this is true, Apache will do a permanent (301) HTTP redirect to http://www.my-domain.com/$1, where $1 is the part that was after the HTTP_HOST.

Now, watch the PageRank of the main domain :)


Tags:



This entry is filed under Linux, Plesk.



6 Responses to “Plesk Linux Domain Alias 301 HTTP Redirect”

  1. Adam Jimenez says:

    great hint. there’s a typo on the last line tho, it should be:

    RewriteEngine on

    # 301 Redirect requests from my-domain.net to my-domain.com
    RewriteCond %{HTTP_HOST} !^(www\.)my-domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.my-domain.com/$1 [L,R=301]

  2. Right. Thanks for correcting that. Post is updated :)

  3. Massimiliano says:

    Thanks Sorin,
    great tip, exactly what i’m looking for!

    Max

  4. Thanks – this is exactly what I was looking for. My Plesk account only gave me 2 physical domains – so now I can add as many as I want and just combine them in 301 and use Domain Alias.

  5. Glad to be helpful :)

  6. OrinocoDelta says:

    WOW, great, but how it works for

    a) Domains without www
    b) Subdomains

    THX for a New Post…. ;-) KIND REGARDS FROM Germany

Leave a Reply




 



Footer left Footer right