Welcome! Log In Create A New Profile

Advanced

problem with requests that have a . in the end of the domain

October 01, 2009 11:44PM
hi

i am currently experiencing some strange behavior if a user requests
our domain with a . in the end of the domain. the actual problem is
that our php code can't really get along with that . in the end of the
domain. so i tried creating an nginx rule that fixes this by doing a
redirect to the correct domain. i tried multiple things, first i just
left our actual production vhost untouched and added an additional one
with the same server_name but with a . in the end of the domain, like
this:

server {
server_name mydomain;
...
}

server {
server_name mydomain.;

rewrite . http://mydomain$request_uri permanent;
}

but i found out that the requests never reach the vhost mydomain., i
also tried to switch the order of those two, but all requests always
go to the vhost mydomain without .

then another thing i tried was to catch the bad request based on the
$host variable like this:

server {
if ($host ~ "^mydomain\.$")
{
rewrite . http://mydomain$request_uri permanent;
}
}

but now when i check the rewrite log i see that this $host variable
doesn't contain the . even if the request did. this means i request
http://mydomain. in my browser and in the rewrite log i see:

2009/10/01 12:23:55 [notice] 8238#0: *3 "^mytdomain\.$" does not match
"mydomain", client: 192.168.56.1, server: mydomain, request: "GET /
HTTP/1.1", host: "mydomain."

i am sure that the browser does not parse this . out, because the php
can see it. and in the end of the above log line you can also see
host: "mydomain.".


does anybody maybe have an idea what else i could do to make sure that
http://mydomain. gets redirected to http://mydomain?

thanks a lot for help

mauro
Subject Author Posted

problem with requests that have a . in the end of the domain

replay October 01, 2009 11:44PM

Re: problem with requests that have a . in the end of the domain

Igor Sysoev October 02, 2009 01:12AM

Re: problem with requests that have a . in the end of the domain

replay October 02, 2009 01:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 189
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