Skip to content

Instantly share code, notes, and snippets.

@ceilidhboy
Created April 13, 2024 20:10
Show Gist options
  • Save ceilidhboy/da96e7e53248bad36cae9d21b01caa83 to your computer and use it in GitHub Desktop.
Save ceilidhboy/da96e7e53248bad36cae9d21b01caa83 to your computer and use it in GitHub Desktop.
Add a www redirect to nginx configuration

Add the following block before the existing server block, in the nginx configuration, where domain-name.com is the domain of the website:

server {
        server_name www.domain-name.com;
        return 301 $scheme://domain-name.com$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment