Rewrite rule for all domains.

Jonathan Matthews contact at
Tue Apr 16 15:07:26 UTC 2013

On 16 April 2013 15:47, David | StyleFlare <david at> wrote:
> Pardon me if I missed this in the docs...
> My issue is that I want to rewrite every domain and not create a server
> block for each.
> I am trying to rewrite every domain thats pointing to Nginx
> from to

Have a single separate server block do it for you:

server {
  listen 80;
  server_name ~^(www\.)(?<domain>.+)$;
  rewrite $scheme://$domain$uri$is_args$args;

(written but not tested; YMMV!)


More information about the nginx mailing list