Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm a programmer whos been thrown into the sys admin world and have a quick question.

I have a web server that I'm trying to add a mobile subdomin for (i.e. m.server.com).

Currently the config looks like:

<VirtualHost *:80>
  ServerName server.com
  ServerAlias www.server.com

  DocumentRoot /home/fc/app/current/public
</VirtualHost>

<VirtualHost *:443>
  ServerName server.com
  ServerAlias www.server.com

  DocumentRoot /home/fc/app/current/public

  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/server.crt
  SSLCertificateKeyFile /etc/ssl/private/server.key
</VirtualHost>

Now I'm thinking that adding a m subdomain that goes to the same place should be easy, right? Would this work:

<VirtualHost *:80>
  ServerName server.com
  ServerAlias www.server.com, m.server.com

  DocumentRoot /home/fc/app/current/public
</VirtualHost>

Thank you!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

That's almost correct, but you don't need the comma between entries in a ServerAlias directive:

ServerAlias www.server.com m.server.com

share|improve this answer
    
Will this redirect the m.server.com to server.com? Currently all the www requests are redirected. I wouldn't want the m subdomain to be cut off. –  Eric Koslow Jul 5 '11 at 13:59
    
nothing shown in your post redirects anything, it just matches and servers files accordingly. There are various things that could redirect your page... rewrite rules in you httpd.conf or in a .htaccess, maybe just a "UseCanonicalName on" or even in the application (CMS, Blog, etc... ) that actually provides your content... –  Marcel G Jul 5 '11 at 14:18
    
OK thank you so much! –  Eric Koslow Jul 5 '11 at 15:01

That would work if you remove the ,. If you don't have any more vhosts, than this two, it would even work without adding m.server.com

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.