Answered by:
Trailing dot in FQDN causing "Bad Request - Invalid Hostname"

Question
-
User1996050903 posted
In IIS6, it was possible to pick up URLs that included a trailing dot in them. e.g. http://www.theogray.co.uk./
In IIS7.x it appears that all requests containing trailing dots (e.g. http://www.microsoft.com./ ) return the following HTML:
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>How do I make IIS 7.5 allow me to respond how I want to requests to URLs that include a trailing dot?
Tuesday, August 10, 2010 11:47 AM
Answers
-
User1632528892 posted
Hi,
I've tried both IE7 and Firefox 3.6.8 from my work PC which sits behind a corporate proxy cluster running (squid/2.6.STABLE21) :
http://cid-534fc5c7633adee5.office.live.com/self.aspx/.Public/IE7.PNG
http://cid-534fc5c7633adee5.office.live.com/self.aspx/.Public/Firefox%203.6.8.PNG
Regards,
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Monday, August 16, 2010 8:12 AM
All replies
-
User-1853252149 posted
How do I make IIS 7.5 allow me to respond how I want to requests to URLs that include a trailing dot?You don't. A trailing dot is an invalid host name and should never be accepted. Stop creating links with trailing dots.
Jeff
Wednesday, August 11, 2010 4:45 AM -
User1996050903 posted
I'm sorry to disagree, but valid FQDNs can include a trailing dot on the end: [FQDN on Wikipedia].
It would also be great to be able to tell everyone around the world that has an email client that includes sentence full stops in automatically converted HREFs to upgrade to a different email client, but unfortunately that is also is not possible.
Finally, if a trailing dot is an invalid host name, then why do the most up-to-date web browsers not remove the trailing dot automatically?
So the question remains; how do I get IIS7.5 to give me back control of how domain names ending in a trailing dot are handled?
Friday, August 13, 2010 6:23 AM -
User-2064283741 posted
I haven't tried this in IIS 7.x yet but I agree I use this on high volume sites in IIS6.(I even posted about it ---http://forums.iis.net/p/1162992/1926350.aspx#1926350)
If more traffic can get to your site and someone mistyping with an additional dot at the end why would you *not* want to serve the page? Serving as many pages as you can is useful.
I'll have a look and see if there is a hack for this but it looks like it is controlled in the http.sys so it might not be possible. What does the http.sys logs say about this? what is the reason error? I presume you have a binding for www.mysite.com. (with the dot at the end)
Friday, August 13, 2010 7:51 AM -
User1996050903 posted
Hello Rovastar,
Thanks for the reply; helping the user easily fix any mistypes that have already resolved to your server is the key here. The bog-standard 400 response that doesn't appear to be over-ridable seems a large backwards step in terms of web-usability.The way I've handled the 4 combinations of a domain name (with/without www. prefix and with/without trailing dot) for the past few years on IIS6 is to have each site with a single host-header (e.g. www.mysite.com) and then the Default Website (with no host-headers assigned) picks up any other domain name that has been pointed at the IP address and does a nice simple 301 redirect including anything else in the URL that is needed. e.g. if a user went to mysite.com./mypage.htm then the script seamlessly redirects them to www.mysite.com/mypage.htm
I have also tried assigning specific host-headers with trailing dots to the sites in questions in IIS 7.5, but that hasn't worked either.
Friday, August 13, 2010 11:24 AM -
User-2064283741 posted
I had a look at this there is different behaviour it seems in IIS 7.x and IIS 6.
In 6 it is was simple you just added the hostheader with the additional . and it picked it up. This is because the http.sys didn't flag it as a bad hostname and fowarded it to IIS which then handled it like any other request.
Sadly there is not much we can do now that the http.sys reject this request. There is little to no configuration of the http.sys and even the lack of decent logging in there e.g. this was rejected by hostname but it doesn't/can't even log what hostname is rejected.
It is a pain and sadly many in the IIS team don't understand the benefits that something like this could bring.
Monday, August 16, 2010 6:50 AM -
User1632528892 posted
Hi,
Am I missing something here ? It looks like you can do this in IIS 7.x :
Regards,
Monday, August 16, 2010 7:20 AM -
User-2064283741 posted
Hi Paul,
I cannot resolve correctly http://www.microsoft.com. (internal network and our external PC tried IE8 and Firefox). It gives:
Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.
Which is server by the http.sys
Server
Microsoft-HTTPAPI/2.0
What do you get? The normal MS site? What browser/proxy are you using (maybe they strip out the following .) ?
Monday, August 16, 2010 7:32 AM -
User1632528892 posted
Hi,
I've tried both IE7 and Firefox 3.6.8 from my work PC which sits behind a corporate proxy cluster running (squid/2.6.STABLE21) :
http://cid-534fc5c7633adee5.office.live.com/self.aspx/.Public/IE7.PNG
http://cid-534fc5c7633adee5.office.live.com/self.aspx/.Public/Firefox%203.6.8.PNG
Regards,
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Monday, August 16, 2010 8:12 AM -
User1632528892 posted
Hi,
I've just tried the same test from home and I get a 400 error with both IE and Firefox.
Regards,
Monday, August 16, 2010 11:00 AM -
User-2064283741 posted
Yeah that must be your work proxy being intelligent.:)
Monday, August 16, 2010 12:30 PM -
User1318071884 posted
I could not find an IIS Connect site but this seems like a reason entry there. http://connect.microsoft.com/directory/servers/Friday, February 25, 2011 2:10 PM -
User1996050903 posted
Thanks jspraul,
I have added a feedback entry to that based on this post for anyone to vote up:
Trailing dot in FQDN causing "Bad Request - Invalid Hostname"
Monday, February 28, 2011 6:22 AM