Mobile app version of vmapp.org
Login or Join
Vandalay111

: Subdomain redirect to WWW 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

@Vandalay111

Posted in: #Apache #Redirects #Subdomain

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 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 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 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"

</VirtualHost>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Vandalay111

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

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
</VirtualHost>


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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme