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

I would like to setup a sub domain on my server at blah.example.com

I am able to reach my USERDIR for each user no problem at example.com/~user

I am unable to setup blah.example.com is there something more with the DNS.

What files do I need to edit. What are the important files to be noted when trying to achieve this setup.

Please and thank you.

share|improve this question
what are you trying to achieve? do you want a subdomain for each user (user.example.com) or one subdomain with the same user dirs (blah.example.com/~user)? –  Marcel G Oct 30 '10 at 2:35
@Marcel I would like to create user.example.com :) –  garbagecollector Oct 30 '10 at 15:47

2 Answers 2

http://httpd.apache.org/docs/2.1/en/vhosts/name-based.html The files you need to edit are depending on your OS (for example in Debian -> a2ensite http://man.he.net/man8/a2ensite / in CentOS you need to edit the httpd.conf file) You must also set a DNS Record like *.yoursite.com

share|improve this answer

this is a modified version of what you can find in the apache httpd rewrite documentation: http://httpd.apache.org/docs/current/rewrite/rewrite_guide.html#uservhosts

You'll have to put the following statements in your httpd.conf (or where ever your custom configuration options for apache are to be set, this varies from distro to distro) and make sure mod_rewrite is enabled.

RewriteEngine on
RewriteCond   %{HTTP_HOST}                  ^[^.]+\.example\.com$
RewriteRule   ^(.+)                         %{HTTP_HOST}$1      [C]
RewriteRule   ^([^.]+)\.example\.com/(.*)   /home/$1/public_html/$2

you'll also need a wildcard DNS entry (*.example.com) pointing to your server IP (or a static dns entry for each and every user which gets a subdomain).


share|improve this answer

Your Answer


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.