Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServerAlias doesn't work

I have problem with ServerAlias directive. Configuration looks like this:

ServerName d.geosurf.ru
ServerAlias www.d.geosurf.ru divo32pro.ru www.divo32pro.ru

But! Everytime when I try to go to divo32pro.ru, for example, i get d.geosurf.ru (servername). It seems like there's no redirect, but something wrong... Any ideas?..

like image 771
Anton Abramov Avatar asked Jul 08 '12 10:07

Anton Abramov


2 Answers

ServerAlias simply declares alternative names that can be used to address the same site (or <VirtualHost>. So if I have

ServerName www.example.com
ServerAlias example.com

I will see the same content for both http://www.example.com/foo/ and http://example.com/foo/.

However, if the Apache server needs to issue a redirect for any reason (for example from a directory name without a trailing slash to the corresponding name with the slash), the behaviour depends on the UseCanonicalName setting. If this is unspecified or Off then it will do what you would expect (http://example.com/foo -> http://example.com/foo/) but if it is set to On then the redirect will be to the ServerName regardless of the original request URL (i.e. http://example.com/foo -> http://www.example.com/foo/). Check if you have this set in your configuration.

like image 133
Ian Roberts Avatar answered Oct 23 '22 16:10

Ian Roberts


ServerAlias doesn't redirect you to the new site.

ServerName just says "here is my server name" and ServerAlias says if anyone goes to X Y or Z then please treat them as if they came direct to ServerName

like image 45
John Mitchell Avatar answered Oct 23 '22 15:10

John Mitchell