[.htaccess] I wish to have my main domain in a directory, like addon domains. How ?

silexian

Registered
Apr 5, 2006
2
0
151
Hello

i would like to have my main domain works with the files in a subdirectory.
Like subdomains.
I don't know how to do that.

Ex: http://www.domain.tld -> /public_html/foo/

I don't want to have in the URL http://www.domain.tld/foo/ but http://www.domain.tld/
Is this possible ?

the reason is that i want to have a directory in /public_html for every site (main domain and addon domains).
Otherwise, this is a mess to distinguish which directories are subdirectories for addon domains or belongs to the main domain.

regards,
silexian
 

GnomeyNewt

Active Member
May 1, 2006
28
1
153
The Stars!
You have two choices:

1) To edit your httpd.conf file.

Find the domain in httpd.conf file.
Edit this line to where you want the domain to load its /home from:

DocumentRoot /home/username/public_html/newdirectory

Save and your done!


2) Less desirable, but it will work.

Create a .htaccess file with the following:

Redirect / http://www.yourdomain.com/newdirectory
 

silexian

Registered
Apr 5, 2006
2
0
151
partially resolved

here is a partial solution for Mambo/Joomla CMS :

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/+(images|templates)$ [NC,OR]
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteRule ^(content/|component/) joomla/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) joomla/$1 [L]
It does work for every URL but the domain (www.domain.tld & www.domain.tld/)

Don't know why.

Anyway, the Basis is the code below for every website (but mambo/joomla) :

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) directory/$1 [L]