Source: paulund.co.uk

Nginx Redirect www to non-www
It's very common these days to see websites that just use the non-www domain and therefore redirect all requests to www to the domain. Below is a quick code snippet you can use to take all requests to www on either http or https and redirect them to the non-www domain. This will listen on both port 80 and 443 for requests to www and perform a 301 redirect to the domain without www.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners