Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the document root of a parked domain?

I have run into a problem which is that my web host doesn't appear offer addon domains.

I currently have a domain name pointing to my name servers.

I went into cPanel to add an addon domain that points to a sub-directory, but all that is available in cPanel is to park domain at the document root which is 'public_html/'.

So traffic coming from the parked domain would get the wrong content, which is obviously not good.

I get the feeling that this isn't possible, but can I change the parked domain document root from 'public_html/' to 'public_html/sub-directory' ?

Or perhaps can I edit the .htaccess file to redirect traffic from the parked domain to the sub-directory?

Basically I want this address; www.parked-domain.com/

To show the content of this sub-directory; www.first-domain.com/parked-directory

I hope this is possible otherwise I need to look at a new web host.

Regards,

Dean.

like image 579
a-second-mix Avatar asked Apr 11 '11 14:04

a-second-mix


People also ask

How do I change the root of a document folder?

You can change the document root directory by moving the contents of the public_html directory to another directory, and then creating a symbolic link that points public_html to the new document root directory.


1 Answers

Add the following to your .htaccess file:

RewriteRule ^parked-directory - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com$ [NC]
RewriteRule ^(.*)$ parked-directory/$1 [L]
like image 89
Gerben Avatar answered Sep 26 '22 03:09

Gerben