May 9th, 2006

How to Park a Domain on an Addon Domain

Web

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.

One Response to ' How to Park a Domain on an Addon Domain '

Subscribe to comments with RSS or TrackBack to ' How to Park a Domain on an Addon Domain '.


  1. on December 9th, 2006 at 11:50 am

    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

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
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.
Click to hear an audio file of the anti-spam word