Apache: Difference between revisions

Adds canonical domain redirect recipe
Line 1: Line 1:
== Docs ==
== Docs ==
In addition to the extensive [http://httpd.apache.org online documentation of the Apache project], you should consult the local documentation on your system under /usr/share/doc/apache2.2-common or similar
In addition to the extensive [http://httpd.apache.org online documentation of the Apache project], you should consult the local documentation on your system under /usr/share/doc/apache2.2-common or similar
== Canonical Domain ==
Here is how we use Apache to answer requests to our multiple registered TLDs, but direct everything to our canonical "bare" domain.
<source lang="apache">
<VirtualHost *:80>
  # redirect 'www' subdomain
  # and all tld aliases
  ServerName      equality-tech.com
  ServerAlias www.equality-tech.com
  ServerAlias    equality-tech.info
  ServerAlias www.equality-tech.info
  ServerAlias    equality-tech.net
  ServerAlias www.equality-tech.net
  ServerAlias    equality-tech.org
  ServerAlias www.equality-tech.org
  Redirect permanent "/" "https://equality-tech.com/"
</VirtualHost>
<VirtualHost *:443>
  ServerName      equality-tech.com
  # answer calls to these numbers as well
  ServerAlias www.equality-tech.com
  ServerAlias    equality-tech.info
  ServerAlias www.equality-tech.info
  ServerAlias    equality-tech.net
  ServerAlias www.equality-tech.net
  ServerAlias    equality-tech.org
  ServerAlias www.equality-tech.org
  ServerAlias equality-tech.local
 
  # forward all calls to our canonical name
  RewriteEngine on
  RewriteCond %{HTTP_HOST} !^equality-tech.com [NC]
  RewriteCond %{HTTP_HOST} !^$
  RewriteRule ^/?(.*) https://equality-tech.com/$1 [L,R=301,NE] 
</source>
* Flags: No Case, Last, Redirect permanent, No Escape <ref>https://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne</ref>
* Response Code: 301 = Permanent <ref>https://tools.ietf.org/html/rfc2616</ref>


== Secure Server ==
== Secure Server ==
Line 105: Line 144:
== Support / Customization ==
== Support / Customization ==
There is a presentation on http://OutOfOrder.cc about Mass Virtual Hosting approaches that is worth a look if you're considering that.  OutOfOrder.cc is a collaborative effort between Paul Querna and Edward Rudd -- two guys who have a lot of experience with Apache.
There is a presentation on http://OutOfOrder.cc about Mass Virtual Hosting approaches that is worth a look if you're considering that.  OutOfOrder.cc is a collaborative effort between Paul Querna and Edward Rudd -- two guys who have a lot of experience with Apache.
{{References}}


[[Category:Howto]]
[[Category:Howto]]