Skip to content

Instantly share code, notes, and snippets.

@desarrolla2
Created July 16, 2012 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desarrolla2/3121439 to your computer and use it in GitHub Desktop.
Save desarrolla2/3121439 to your computer and use it in GitHub Desktop.
Canonical Hostnames
# Description: The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [L,R]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment