0

I'm the admin of an apache server (on a hosting package that allows me to host multiple domains), I've got one domain in public_html (let's call it www.ROOTwebsite.com) and 9 other domains hosted in a folder in the same directory level as the public_html, called DOMAINS.

So the structure is:

-DOMAINS/site1.com/
        /site2.com/ ... etc
-public_html

I'm using '/' in the beginning of all relative paths in wamp for site1.com (for example /menu.php) and it works fine, but when I upload to DOMAINS/site1.com/ it messes up the site because it obviously is looking at the public_html directory as the ROOT.

I've used a number of combinations on the following in the .htaccess file, but I can't figure out which is the right syntax to change the ROOT to a directory sitting NEXT to public_html, not under it as usual:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ROOTwebsite.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^ROOTwebsite.gr$
RewriteCond %{REQUEST_URI} !DOMAINS/site1.com/
RewriteRule (.*) /DOMAINS/site1.com/$1 [L]

I wish to change the root directory for site1.com so that it also works with the '/', without affecting the public_html website.

Can anyone see the problem with the code above?

noiz
  • 3
  • 5

2 Answers2

0

You cannot redefine the document root via .htaccess. You have to create different vhosts for the domains that then can have separate document roots.

ChristianM
  • 1,793
  • 12
  • 23
  • My problem is the online management on the shared server. How can I host the sites in the DOMAINS folder in vhosts? – noiz Jun 12 '15 at 14:26
0

The closest I have come to redefine a document root via .htaccess is the following (not exactly what you are asking, because in my example, site1.com is a subdir of the main document root, but this would achieve what you want, with the caveat below).

RewriteCond %{HTTP_HOST} ^site1.com$ [NC]
RewriteRule !^site1.com/ /site1.com%{REQUEST_URI} [L,NC]

this will effectively redirect all site1.com to the site1.com subdirectory. [caveat] The only problem I could not solve is how to redirect an url that goes directly to the subdirectory such as http://site1.com/site1.com/index.html to http://site1.com/index.html

andrea m.
  • 668
  • 7
  • 15