Skip to content

Instantly share code, notes, and snippets.

@ErDmKo
Last active December 20, 2015 06:59
Show Gist options
  • Save ErDmKo/6090237 to your computer and use it in GitHub Desktop.
Save ErDmKo/6090237 to your computer and use it in GitHub Desktop.
www redirect
if request.get_host().split(".")[0] == 'www':
return HttpResponseRedirect((request.is_secure() and "https" or "http")+ "://"+".".join(request.build_absolute_uri().split(".")[1:]))
server {
listen 80;
server_name www.dom.ru;
return 301 $scheme://dom.ru$request_uri;
}
server {
listen 80;
server_name dom.ru;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment