ServerAlias doesn't work
Asked Answered
C

2

8

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?..

Culminate answered 8/7, 2012 at 10:57 Comment(1)
I know this is dead old, but maybe will help someone. If you some CMS, probably the problem isn't ServerAlias, but the the URL specified in your configuration. CMS tend to redirect you on the correct domain when you access from something else.Eddings
S
13

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.

Segmentation answered 8/7, 2012 at 11:37 Comment(0)
I
3

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

Ivied answered 8/7, 2012 at 11:11 Comment(4)
wait a minute... i thought if i set up new ServerAlias it means that i can go to new domain name and see the same site, but it'll be look like i came to another address without any changes in the url nameCulminate
Have a peek at httpd.apache.org/docs/2.0/vhosts/name-based.html when you visit the site for the first time your URL will be that of the url you came in on, and if you use relative only links they will link to the url you came in on, but if you use aboslute links it will direct you to the "real site" it doesn't do re-writing, for that you need mod_rewrite. It just tells apache what site to show, if your using name based hosting then it matches a Alias just like a Name and displays the correct site.Ivied
when i visit divo32pro.ru (whithout any links) its changes by server to d.geosurf.ru (servername) without redirectCulminate
As in the url bar changes to d.geosurf.ru ? If so you have a 302 or similar redirection in place.Ivied

© 2022 - 2024 — McMap. All rights reserved.