ezra_z
November 8, 2007, 12:16am
1
Hi there-
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?
Thanks
Ezra Z.
Founder & Ruby Hacker
[email protected]
ezra_z
November 8, 2007, 12:48am
2
I think the docs have the wrong variable name here. I’ve been using
$http_host instead of $host in my configs without issue.
ezra_z
November 8, 2007, 12:48am
3
I think the docs have the wrong variable name here. I’ve been using
$http_host instead of $host in my configs without issue.
ezra_z
November 8, 2007, 5:19am
4
On Nov 7, 2007 11:10 PM, Wayne E. Seguin [email protected] wrote:
On Nov 7, 2007 6:06 PM, Ezra Z. [email protected] wrote:
if ( $host ~* (.?.?foo.com).)$ {
set $domainwithoutdot $1;
rewrite ^(. )$ http://$domainwithoutdot$1 permanent;
}
Ezra,
Why is the ‘$’ outside the if() parenthesis? Also try $http_host.
What I meant to say (wasn’t supposed to be a question) is try moving
the $ just after the .
~Wayne
ezra_z
November 8, 2007, 8:22am
5
On Wed, Nov 07, 2007 at 03:06:16PM -0800, Ezra Z. wrote:
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.
ezra_z
November 9, 2007, 1:07am
6
Hi~
On Nov 7, 2007, at 11:15 PM, Igor S. wrote:
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
ezra_z
November 8, 2007, 5:19am
7
On Nov 7, 2007 6:06 PM, Ezra Z. [email protected] wrote:
if ( $host ~* (.?.?foo.com).)$ {
set $domainwithoutdot $1;
rewrite ^(. )$ http://$domainwithoutdot$1 permanent;
}
Ezra,
Why is the ‘$’ outside the if() parenthesis? Also try $http_host.
~Wayne