Welcome! Log In Create A New Profile

Advanced

Re: Rewrite rule for all domains.

António P. P. Almeida
April 16, 2013 11:20AM
Adding to Jonathan suggestion with a twist:

1. Use a map directive at the http level:

map $host $rewrite_domain {
default 0;
~www\.(?<domain>.*)$ $domain;
}

2. Create a default server while leaving all vhosts using only the base
domain.

server {
listen 80 default_server;

if ($rewrite_domain) {
return 301 $scheme://$rewrite_domain$request_uri;
}
}

----appa



On Tue, Apr 16, 2013 at 4:47 PM, David | StyleFlare <david@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
>
> currently I am doing uwsgi_pass unix://$host.sock
>
> but if the host name has the www prefix then my socket is not found...
>
> Currently I am using the default nginx.conf file with only one line added
> uwsgi_pass
>
> Thanks in advance for any help.
>
>
>
>
>
>
> ______________________________**_________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/**mailman/listinfo/nginxhttp://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite rule for all domains.

David | StyleFlare April 16, 2013 10:48AM

Re: Rewrite rule for all domains.

Jonathan Matthews April 16, 2013 11:08AM

Re: Rewrite rule for all domains.

David | StyleFlare April 16, 2013 11:16AM

Re: Rewrite rule for all domains.

António P. P. Almeida April 16, 2013 11:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready