Skip to content

Instantly share code, notes, and snippets.

@macek
Created September 29, 2010 21:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save macek/603643 to your computer and use it in GitHub Desktop.
Save macek/603643 to your computer and use it in GitHub Desktop.
Redirect without www on Nginx and Engine Yard
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Custom server level rewrites go here.
# This means that you can also enter custom rewrite locations here.
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ http://$host_without_www$1 permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment