Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the domain example.com and the test.example.com running on apache server. For some reason when I try to visit test.example it is redirected to www.test.example and by consequence a Server not found error is displayed in the browser. Both .htaccess (root and subdomain folder) files are empty.

Additional facts

I have another subdomain xyz.example.com pointed to public_html/xyz directory with some content inside (index.html with "hello world message") and it works fine if I use xyz.example.com instead of www.xyz.example.com. So, can you help me to point to the right direction in order. I have a vps and I am able to change any file if is required.

Below you can find my virtual host configuration.

<VirtualHost xx.xxx.xxx:80>
    ServerName test.example.com
    ServerAlias www.test.example.com
    DocumentRoot /home/example/public_html/test
    ServerAdmin webmaster@test.example.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/test.example.com combined
    CustomLog /usr/local/apache/domlogs/test.example.com-bytes_log "%{%s}t %I  .\n%{%s}t %O ."

    ScriptAlias /cgi-bin/ /home/example/public_html/test/cgi-bin/

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/example/test.example.com/*.conf"

share|improve this question
Why are you using ServerAlias www.test.example.com if you don't need it? – j0k Sep 6 '12 at 5:22
Because when I saw the othres virtual servers (auto-generated by cpanel) I thought that this property was required – manix Sep 6 '12 at 5:25
Looks like a similar problem to: webmasters.stackexchange.com/questions/34165/… – w3dk Sep 6 '12 at 8:23

The issue here will be the ServerAlias directive. Duplicating vhost files from other sites can be an issue as you don't need to have all those directives. The bare bones vhost file you need is...

<VirtualHost xx.xxx.xxx:80>
    ServerName test.example.com
    DocumentRoot /home/example/public_html/test

Everything else in the vhost is additional directives to add if you need them, such as custom log locations, alias records, etc.

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.