Web

How to Park a Domain on an Addon Domain

If you're using a shared host with CPanel, no doubt you are getting familiar with addon domains and parked domains. You may have parked a domain already on your main domain. Recently however, I wanted to park a domain on an addon domain, and was told that this is impossible. Well, I've found of using the .htaccess file that works well enough.

Just to be clear: an addon domain is a fully functional domain that can be created from your cpanel. Once it's created it will have it's own email, and it's own folder from within the public_html directory. Parked domains are place holder sites. You park them on top of another site and they become a single page of the site you park it on.

Basically I had this situation, domain names have been changed of course:

  • www.mysite1.com is an addon domain in my shared hosting account. The folder is /public_html/mysite1/.
  • www.mysite2.com I want to point to www.mysite1.com. The folder is /public_html/mysite2/.

I was told to just set up a simple redirect. I could have done this with PHP, and put index.php in /public_html/mysite2/, redirecting to www.mysite1.com. Or I could have put a simple redirect rule in .htaccess. But this would only work at the root domain level. In other words, if someone requested www.mysite2.com/support (or any other page/directory), it would always redirect to the root domain of www.mysite1.com. So I dug up this good workaround with .htaccess, which allows any request to be forwarded to the same page/directory of another domain. So www.mysite2.com/support would go to www.mysite1.com/support.

Here's the .htaccess code, put it in the folder you wish to redirect. In my case that's /public_html/mysite2/


RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite2.com$
RewriteRule ^(.*)$ http://www.mysite1.com/$1 [R=301,L]

By the way, the trailing slash is vital for this to work.

Share

4 Comments

  1. vietnam news tin tức âm nhạc giải trí 24 giờ news

    thank for this article that all i need for my site
    i will post it in my vietnam news forums
    http://www.xaluan.com/modules.php?name=Forums
    regards

  2. When I add a parked domain using CPanel X it does not create a directory under public_html. So, in your examples above there is no public_html/mysite2. Sure, there is a directory public_html/mysite1 if mysite1.com is an add-on domain but not if it's a parked domain. Not sure therefore where you are supposed to put this .htaccess file.

  3. it is not park method it is redirect.
    your article title must be change to how redirect domain by apache htaccess.

    !!!!!!!

  4. Addon Domains - Solving duplicate content issue using .htaccess

    […] also: How to Park a Domain on an Addon Domain. Article by Manish […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image