Differences between current version and revision by previous author of NameVirtualHosting.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 5 | Last edited on Sunday, February 25, 2007 12:07:34 pm | by TimCareySmith | |
Older page: | version 3 | Last edited on Saturday, February 24, 2007 3:29:04 pm | by AristotlePagaltzis | Revert |
@@ -49,9 +49,10 @@
ErrorLog /var/log/apache/example.co.nz-error.log
</VirtualHost>
<VirtualHost *>
- ServerName example.co.nz
+ ServerName aliases.for.www.example.co.nz
+ ServerAlias
example.co.nz
ServerAlias example.com
ServerAlias www.example.com
RedirectMatch 301 /?(.*) http://www.example.co.nz/$1
</VirtualHost>
@@ -59,4 +60,15 @@
With this configuration, any and every request for a page on one of the alias domains, eg. <tt>~http://example.com/products/</tt>, will redirect the visitor the same page in the canonical domain, in this case <tt>~http://www.example.co.nz/products/</tt>.
There are other ways to achieve this, such as using mod_rewrite, but none of them is as simple as this one.
+
+The advantage with using the <tt>aliases.for.www.example.co.nz</tt> as the <tt>~ServerName</tt> in the second <tt>~VirtualHost</tt> is that when using the command <tt>apache2ctl -S</tt> you get the following output:
+
+<verbatim>
+ port 80 namevhost www.example.co.nz
+ (/etc/apache2/sites-enabled/ubersite.conf:3)
+ port 80 namevhost aliases.for.www.example.co.nz
+ (/etc/apache2/sites-enabled/ubersite.conf:11)
+</verbatim>
+
+This allows you to easily identify the alias <tt>~VirtualHost</tt>s.