Global www removal/redirect?

Denis F. Latypoff denis at gostats.ru
Tue Jun 10 15:35:29 MSD 2008


Hello Igor,

Tuesday, June 10, 2008, 6:05:17 PM, you wrote:

> 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?;

ok, that did the trick, thanks ;)

-- 
Best regards,
 Denis                            mailto:denis at gostats.ru






More information about the nginx mailing list