Redirect www to no-www with variable (for multiple domains)?

Edho Arief edho at myconan.net
Mon Jul 8 04:47:08 UTC 2013


On Sun, Jul 7, 2013 at 6:30 PM, lennart <nginx-forum at nginx.us> wrote:
>
> Is there a way to do this with regex or variables? I've ~15 domains and it
> would be more convenient to have only one entry "to rule them all" ;-)
>

the regex way, which is supposedly slower:

server {
  server_name ~^www\.(?<domain>.+)$;
  listen 80; listen [::]:80;
  return 301 $scheme://$domain$request_uri;
}

--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the nginx mailing list