Ucodice Technologies
Ucodice Technologies Pvt. Ltd.
Ucodice Technologies Pvt. Ltd.
Ucodice Technologies Pvt. Ltd.

Without www wrong virtual host is opening

Suppose you are opening a website without www & it is showing different website content then issue is with your Virtual host entries. Recently I was configuring a virtual host for one of my website.  After configuration I have noticed that without www first virtual host website is opening.

 

For example I have configured 2 virtual hosts on my server.

 

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com

# Other directives here

</VirtualHost>

 

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.com

# Other directives here

</VirtualHost>

 

When I open example2.com without www it is showing content of example.com not example2.com

 

Solution for this issue is to defining ServerName & ServerAlias Properly.  For example

 

ServerName example.com

ServerAlias *.example.com

 

<VirtualHost *:80>


DocumentRoot /www/example2
ServerName example2.com

ServerAlias *.example.com

# Other directives here

</VirtualHost>

Ucodice Technologies
Ucodice Technologies Pvt. Ltd.
Ucodice Technologies Pvt. Ltd.
Ucodice Technologies Pvt. Ltd.
Menu

Comments

Please share your views with us

Check if you want to display your email-id.

Let's collaborate

write to us

contact@ucodice.com

Contact Form