a tricky problem with subdomains

Using a single web hosting account to host multiple sites

a tricky problem with subdomains

Postby kostis » Wed Apr 09, 2008 7:11 am

Hi everybody!
Excellent forum, truly saved my life on many occasions.
But i'm stuck with the following problem:

i already have managed setting up subdomains for all the users of the domain like:
username.domain.com > www.domain.com/username

However i want the static.domain.com and admin.domain.com to be real subdomains with their own .log and .conf files... (the static will at some point be hosted at amazon S3)


Any help greatly appreciated.

Thanks, Kostis
kostis
 
Posts: 3
Joined: Wed Apr 09, 2008 7:00 am
Location: Greece

Postby richardk » Wed Apr 09, 2008 2:08 pm

See: Virtual sub domains. If you have any problems, post back here.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kostis » Thu Apr 10, 2008 3:15 am

thnx richardk for your swift reply.

I took a look at the httpd.conf of the server and saw that, unfortunately, the mod_vhost_alias is not included. I don't have the technical expertise to add it and even if i could i'd probably disrupt the way the other domains there are served by apache.

I should have added on my first post that i have found a (not so optimal) solution that does the trick (it's added on the .conf file)

ServerName *.example.com
ServerAlias *.example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ /www/$1 [L]
RewriteCond %{HTTP_HOST} ^www.*
RewriteRule ^(.*)$ /www/$1 [L]
RewriteCond %{HTTP_HOST} ^admin.*
RewriteRule ^(.*)$ /admin/$1 [L]
RewriteCond %{HTTP_HOST} ^static.*
RewriteRule ^(.*)$ /static/$1 [L]
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ /users/$1 [L]

but the problem, as i already mentioned, is that i don't have separate .log files for the admin & static subdomains but more importantly that i observe a significant delay when i try to browse the subdomains (i guess it's because of all the above rules)
kostis
 
Posts: 3
Joined: Wed Apr 09, 2008 7:00 am
Location: Greece

Postby richardk » Thu Apr 10, 2008 2:50 pm

As far as i can see you don't need mod_rewrite or mod_vhost_alias as you are not using the username in the "document root". Try
Code: Select all
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /the/document/root/www
</VirtualHost>

<VirtualHost *:80>
  ServerName admin.example.com
  DocumentRoot /the/document/root/admin

  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  CustomLog logs/admin common
</VirtualHost>

<VirtualHost *:80>
  ServerName static.example.com
  DocumentRoot /the/document/root/static

  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  CustomLog logs/static common
</VirtualHost>

<VirtualHost *:80>
  ServerName 0.example.com
  ServerAlias *.example.com
  DocumentRoot /the/document/root/users
</VirtualHost>

You'll probably want to check the log is formatted how you want it. also be aware of the File Descriptor Limits (or, Too many log files).
Last edited by richardk on Mon Apr 14, 2008 2:55 pm, edited 1 time in total.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kostis » Mon Apr 14, 2008 3:02 am

thnx richardk, you saved me
I feel rather embarrassed though, it was such a simple solution

thnx again
kostis
 
Posts: 3
Joined: Wed Apr 09, 2008 7:00 am
Location: Greece


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 20 guests

cron