Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 8th August 2012, 03:42
tahunasky tahunasky is offline
Member
 
Join Date: Jul 2012
Location: Buenos Aires
Posts: 84
Thanks: 1
Thanked 8 Times in 8 Posts
Default Apache - same subdomain on multiple domains

hi,

Is there a way in apache to have the same subdomain on multiple domains point to the same doc root without having to have a virtualhost directive for each domain.
I am hosting multiple domains on the same server with the same subdomain names - mail.domain1.com & cloud.domain1.com, mail.domain2.com & cloud.domain2.com, mail.domain3.com & cloud.domain3.com etc and want all the mail subdomains to point to /opt/webmail/ and all the cloud subdomains to point to /opt/cloud/. I have tried the below but it doesnt work.

Code:
<VirtualHost *:443> 
  Servername mail.domain1.com
  ServerAlias mail.* 
  DocumentRoot /opt/webmail 
</VirtualHost> 

<VirtualHost *:443>
  Servername cloud.domain1.com 
  ServerAlias cloud.* 
  DocumentRoot /opt/cloud 
</VirtualHost>
I would like something that i dont have to touch again even if i add/remove domains - any ideas how i can do this ?

thanks

Last edited by tahunasky; 8th August 2012 at 15:43.
Reply With Quote
Sponsored Links
  #2  
Old 8th August 2012, 15:29
TiTex TiTex is offline
Senior Member
 
Join Date: Aug 2011
Location: Cluj-Napoca,Romania
Posts: 125
Thanks: 0
Thanked 18 Times in 17 Posts
Send a message via Skype™ to TiTex
Default

Code:
<VirtualHost *:443> 
Servername mail.domain1.com
ServerAlias mail.domain2.com
ServerAlias mail.domain3.com
DocumentRoot /opt/webmail 
</VirtualHost> 

<VirtualHost *:443>
Servername cloud.domain1.com 
ServerAlias cloud.domain2.com
ServerAlias cloud.domain3.com  
DocumentRoot /opt/cloud 
</VirtualHost>
Reply With Quote
  #3  
Old 8th August 2012, 15:42
tahunasky tahunasky is offline
Member
 
Join Date: Jul 2012
Location: Buenos Aires
Posts: 84
Thanks: 1
Thanked 8 Times in 8 Posts
Default

Quote:
Originally Posted by TiTex View Post
Code:
<VirtualHost *:443> 
Servername mail.domain1.com
ServerAlias mail.domain2.com
ServerAlias mail.domain3.com
DocumentRoot /opt/webmail 
</VirtualHost> 

<VirtualHost *:443>
Servername cloud.domain1.com 
ServerAlias cloud.domain2.com
ServerAlias cloud.domain3.com  
DocumentRoot /opt/cloud 
</VirtualHost>
Thanks for the reply, however this is basically what i have now, except i have:

Code:
<VirtualHost *:443> 
  Servername mail.domain1.com
  ServerAlias mail.domain2.com mail.domain3.com
  DocumentRoot /opt/webmail 
</VirtualHost> 

<VirtualHost *:443>
  Servername cloud.domain1.com 
  ServerAlias cloud.domain2.com cloud.domain3.com  
  DocumentRoot /opt/cloud 
</VirtualHost>
I dont want to have to add to the serveralias line everytime i add a new domain, or remove from serveralias everytime i delete a domain.

I am trying to do something where i dont have to add/delete when i add or remove domains, just set it up once with wildcards or whatever and it works with all domains.
Reply With Quote
  #4  
Old 8th August 2012, 16:18
TiTex TiTex is offline
Senior Member
 
Join Date: Aug 2011
Location: Cluj-Napoca,Romania
Posts: 125
Thanks: 0
Thanked 18 Times in 17 Posts
Send a message via Skype™ to TiTex
 
Default

i don't think that the wildcard works after the subdomain
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache hangs without traffic Thesee General 21 27th September 2011 23:43
Something blocking port 53 stigge2000 Installation/Configuration 4 5th April 2011 14:46
Add logo in multiple vhosted domains archbird Programming/Scripts 1 5th November 2010 14:29
Fixing 404 Not Found Errors on Apache on Centos 5 x86_64 Dedi LinuxOnMyMac HOWTO-Related Questions 11 16th October 2010 04:29
trying to install roundcubemail ressel Installation/Configuration 13 24th December 2009 20:13


All times are GMT +2. The time now is 09:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.