You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ivan Zanev <iv...@gmail.com> on 2008/12/22 19:33:41 UTC

[users@httpd] Subdomains Hosting Continuation

Well, thanks for the replies, you all! Here's what i did: I've create a
sdsymlinks folder with symbolic links to the users subdomains. The htaccess
is using the symlink, but here is what happens in several cases:

Let Superman has the x subdomain at thehost.com. That is: x.thehost.com

We access x.thehost.com: Everything works fine and index.html opens.

We access x.thehost.com/images: The images folder does not exist. Instead of
displaying the Not Found error, we end up with recursion of urls. (will
explain later).

We access x.thehost.com/images: The images folder exists. A list of files is
displayed with the "Up One Level" link. We click on the Up on Level link.
Instead of going into x.thehost.com (as it is the parent of
x.thehost.com/images), we end up in x.thehost.com/files/sdsymlinks/x. Now
let me walk you through my .htaccess file:

<IfModule rewrite_module>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/$
    RewriteCond %{HTTP_HOST} !^((cp\.)|(www\.)|(admin\.))
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.besthost-bg\.com$
    RewriteRule (.*) files/sdsymlinks/%1/index.html [QSA,L]

    RewriteCond %{REQUEST_URI} !^/$
    RewriteCond %{REQUEST_URI} !files/sdsymlinks/
    RewriteCond %{HTTP_HOST} !^((cp\.)|(www\.)|(admin\.))
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.besthost-bg\.com$
    RewriteRule (.*) files/sdsymlinks/%1/$1 [QSA,L]

    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule (.*) index.php?url=$1 [QSA,L]
</IfModule>

The first pair of conditions check if we are trying to access
x.thehost.com(the REQUEST_URI is '/'). If this is the case, we will
open index.html.
The second pair of conditions check if we are trying to access
x.thehost.com/something (the REQUEST_URI is not '/'). We also check if the
REQUEST_URI matches files/sdsymlinks/. Now, why would I want to do that? The
answer is, if I remove this
condition, we end up with recursion.  files/sdsymlinks/x is rewritten to
files/sdsymlinks/x/files/sdsymlinks/x/ and so on, until the recursion is
internally stopped from apache.
The third pair works if the subdomain is cp or www or admin in which cases
we don't want to go to the files/sdsymlinks.

The problem is: I don't feel it right, because for every automatic
operation, I must take care myself => not found, forbidden and so on. I've
seen some hosting sites, where you can have a subdomain, no problem and
everything works fine. But I can't get it right. Please help me!