atom feed7 messages in ru.sysoev.nginxRe: Rewrite foo.com. to foo.com
FromSent OnAttachments
Ezra ZygmuntowiczNov 7, 2007 3:05 pm 
Eden LiNov 7, 2007 3:40 pm 
Eden LiNov 7, 2007 3:42 pm 
Wayne E. SeguinNov 7, 2007 8:10 pm 
Wayne E. SeguinNov 7, 2007 8:12 pm 
Igor SysoevNov 7, 2007 11:15 pm 
Ezra ZygmuntowiczNov 8, 2007 3:56 pm 
Subject:Re: Rewrite foo.com. to foo.com
From:Ezra Zygmuntowicz (ezmo@public.gmane.org)
Date:Nov 8, 2007 3:56:14 pm
List:ru.sysoev.nginx

Hi~

On Nov 7, 2007, at 11:15 PM, Igor Sysoev wrote:

On Wed, Nov 07, 2007 at 03:06:16PM -0800, Ezra Zygmuntowicz wrote:

I'm trying to sort out a problem a client is having with a googlemap api key. I need to rewrite any requests that end in a . to the same request with no .

example:

incoming request to foo.bar.com. needs to be rewritten to foo.bar.com with no trailing dot , but retaining any uri so

foo.bar.com./qux -> foo.bar.com/qux

Any ideas on how to accomplish this? I tried something like this:

if ( $host ~* (.*?\.?foo\.com)\.)$ { set $domainwithoutdot $1; rewrite ^(.*)$ http://$domainwithoutdot$1 permanent; }

Help?

As it was already said, you should use $http_host, because $host is the cooked header with stripped possible dot.

Thanks everyone. here is the final working version for posterity:

if ( $http_host ~* (.*?\.?foo\.com)\.) { set $domainwithoutdot $1; rewrite ^(.*)$ http://$domainwithoutdot$1 permanent; }

Cheers- -Ezra