RAM Host Community Forums

Knowledge and Help for our Customers (and everyone else)

You are not logged in.

#1 29 Jun 2010 6:01:21 pm

ramnet
Moderator
From: USA
Registered: 15 Nov 2009
Posts: 582
Website

Hosting Main Domain From A SubDirectory

Copy and paste the following code into the .htaccess file in the public_html folder of your hosting account (/home/yourusername/public_html)

Replace all instances of "example.com" with your main domain (usually the one you specified when you ordered the service - and the one specified on your invoices) and your site will be served from /home/username/public_html/example.com/ instead of from /home/username/public_html/

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example.com/index.php [L]

In that last line, you may need to modify index.php to be index.html or something else depending on what kind of files you have:

Last edited by ramnet (29 Jun 2010 6:01:53 pm)


Alex, RAM Host

Offline

#2 24 Nov 2010 3:29:13 am

himagain
Member
Registered: 15 Jan 2010
Posts: 62

Re: Hosting Main Domain From A SubDirectory

Hi there,
Interesting scripting - but why would you do it? 


Cheers!

Offline

#3 25 Nov 2010 10:37:35 pm

ibnuasad
Member
Registered: 17 Nov 2009
Posts: 32

Re: Hosting Main Domain From A SubDirectory

himagain wrote:

Interesting scripting - but why would you do it?

Some people might have multiple domains and want to arrange them in a subfolder neatly...eg:

public_html/business/maindomain.com
public_html/business/domain2.com

public_html/personal/domain3.com
public_html/personal/domain4.com

smile

Offline

#4 26 Nov 2010 4:26:35 pm

himagain
Member
Registered: 15 Jan 2010
Posts: 62

Re: Hosting Main Domain From A SubDirectory

Thanks for that - to both of you!   :-)

Offline

Board footer

Powered by FluxBB