Rewrite rule for all domains.

David | StyleFlare david at styleflare.com
Tue Apr 16 15:15:15 UTC 2013


Thanks, I will test it.

Appreciate it.


On 4/16/13 11:07 AM, Jonathan Matthews wrote:
> On 16 April 2013 15:47, David | StyleFlare <david at styleflare.com> 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 www.server.com to server.com
> 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!)
>
> Jonathan
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list