subdomain to other documentroot

Using a single web hosting account to host multiple sites

subdomain to other documentroot

Postby commentator » Fri Jul 25, 2008 4:00 pm

Hi,

I would like to do the following for the webmail subdomains:
webmail.<all domains here> to /var/www/webmailclient/
webmail2.<all domains here> to /var/www/webmailclient/

*.<all domains here> to /var/www/default/

<all domains here> = for every domain hosted

is this possible ?
and how to do this?
commentator
 
Posts: 10
Joined: Sat Jul 21, 2007 10:47 am

Postby richardk » Sat Jul 26, 2008 3:51 am

Do you have access to the httpd.conf file? You can use the following <VirtualHost>s
Code: Select all
<VirtualHost *:80>
  ServerName   _default_
  DocumentRoot /var/www/default
</VirtualHost>

<VirtualHost *:80>
  ServerName   webmail.example.com
  ServerAlias  webmail.* webmail2.*
  DocumentRoot /var/www/webmailclient
</VirtualHost>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby commentator » Sat Jul 26, 2008 6:44 am

richardk wrote:Do you have access to the httpd.conf file? You can use the following <VirtualHost>s

Yes but I want to to this for https, so there is only one VirtualHost possible.
That's why I'm trying to rewrite it :)
commentator
 
Posts: 10
Joined: Sat Jul 21, 2007 10:47 am

Postby richardk » Sat Jul 26, 2008 2:42 pm

Yes but I want to to this for https, so there is only one VirtualHost possible.

Why does https make it not possible?

I'm not sure you can change the document root unless you remove the DocumentRoot from the <VirtualHost> or at all. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^webmail2?\. [NC]
RewriteRule ^(/.*)$ /var/www/webmailclient$1 [PT,L]


What is your current <VirtualHost> like?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby commentator » Sun Jul 27, 2008 7:41 am

richardk wrote:
Yes but I want to to this for https, so there is only one VirtualHost possible.

Why does https make it not possible?

Hi, Thanks for your reply.

Only one virtualhost for an ip allowed

richardk wrote:I'm not sure you can change the document root unless you remove the DocumentRoot from the <VirtualHost> or at all. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^webmail2?\. [NC]
RewriteRule ^(/.*)$ /var/www/webmailclient$1 [PT,L]


I want it for the subdomains webmail and webmail2
all other subdomains (including www) -> /var/www/default


richardk wrote:What is your current <VirtualHost> like?


Code: Select all
<VirtualHost myip:443>
ServerName webmail
ServerAlias webmail.*
DocumentRoot /var/www/webmailclient

DirectoryIndex index.html index.php

AddType application/x-httpd-php .php .php3 .php4 .php5
UseCanonicalName Off

SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem

</VirtualHost>

but now every request is redirected to my webmailclient

so www.domain.co = webmail.domain.co
thats why I want to rewrite the dir
commentator
 
Posts: 10
Joined: Sat Jul 21, 2007 10:47 am

Postby richardk » Tue Jul 29, 2008 11:29 am

Couldn't you use * instead of the ip address for the <VirtualHost>?

You can try
Code: Select all
<VirtualHost myip:443>
  ServerName _default_
  DocumentRoot /var/www/default

  Options +FollowSymLinks

  RewriteEngine On

  RewriteCond  %{HTTP_HOST} ^webmail2?\. [NC]
  RewriteRule ^(/.*)$ /var/www/webmail$1 [PT,L]

  DirectoryIndex index.html index.php

  AddType application/x-httpd-php .php .php3 .php4 .php5
  UseCanonicalName Off

  SSLEngine on
  SSLCertificateFile /etc/apache2/apache.pem
</VirtualHost>

But it'll probably make it /var/www/default/var/www/webmail.

What is your working <VirtualHost> (not the webmail one)?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby commentator » Tue Jul 29, 2008 1:34 pm

rewrite not working:
Code: Select all
[Tue Jul 29 23:26:08 2008] [error] [client xxx] File does not exist: /var/www/default/var


looks like the rewrite writes behind the document root

I have only one vhost for https
so all https shows now the webmail and I want to prevent that, that;s why I want to rewrite the docroot
commentator
 
Posts: 10
Joined: Sat Jul 21, 2007 10:47 am

Postby richardk » Wed Jul 30, 2008 3:41 pm

Did you have a 403 <VirtualHost> before you started this? If you did, post it.

Try
Code: Select all
<VirtualHost myip:443>
  ServerName _default_
  DocumentRoot /var/www

  Options +FollowSymLinks

  RewriteEngine On

  RewriteCond  %{HTTP_HOST} ^webmail2?\. [NC]
  RewriteRule ^(/.*)$ /webmail$1 [PT,L]

  RewriteRule ^(/.*)$ /default$1 [PT,L]

  DirectoryIndex index.html index.php

  AddType application/x-httpd-php .php .php3 .php4 .php5
  UseCanonicalName Off

  SSLEngine on
  SSLCertificateFile /etc/apache2/apache.pem
</VirtualHost>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby commentator » Fri Aug 01, 2008 12:18 pm

403 error for subdirs
commentator
 
Posts: 10
Joined: Sat Jul 21, 2007 10:47 am

Postby richardk » Fri Aug 01, 2008 3:32 pm

What is the URL (webmail or something else, what subdirectory, etc.)?
What does your error log say about the error?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 15 guests

cron