ServerName

From LQWiki
Jump to navigation Jump to search

ServerName is a configuration parameter from the apache configuration files.

It allows you to serve different content to http requests that go to the same IP address, but to different server names. Let's look at an example:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.foo.com
ServerAlias foo.com *.foo.com
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost *:80>
ServerName www.bar.org
DocumentRoot /srv/www/htdocs/bar
</VirtualHost>

Here, requests for www.foo.com are served from /srv/www/htdocs, but requests for www.bar.org are served from /srv/www/htdocs/bar. For more information, see http://httpd.apache.org/docs/2.2/mod/core.html