Global www removal/redirect?

Igor Sysoev is at rambler-co.ru
Tue Jun 10 15:05:17 MSD 2008


On Tue, Jun 10, 2008 at 05:48:58PM +0700, Denis F. Latypoff wrote:

> Hello Igor,
> 
> Tuesday, June 10, 2008, 5:02:38 PM, you wrote:
> 
> > On Tue, Jun 10, 2008 at 09:59:55AM +0100, Phillip B Oldham wrote:
> 
> >> Is there a quick way to remove the redirect from http://www.* to 
> >> http://* without listing all the domains? I'm about to point a couple of 
> >> hundred domains to a box running nginx, and need to remove all the www's 
> >> from the urls for the app to work.
> 
> >    server {
> >        server_name  www.*;
> 
> >        if ($http_host ~* ^www\.(.+)$) {
> >            set  $h   $1;
> >        }
> 
> >        rewrite   ^   http://$h$request_uri;
> >    }
> 
> 
> by the way, Igor, this rule will rewrite
> 
> http://www.domain.com/path?arg=value
> to
> http://domain.com/path?arg=value?arg=value
> 
> as well as the 'rewrite ^(.*) http://$h$1;'
> 
> just found it.

Then

-       rewrite   ^   http://$h$request_uri;
+       rewrite   ^   http://$h$request_uri?;


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list