Yesterday we handled the 500 error in Google Webmaster and handled some 400 processing today, such as the following URL at the End of tab (tab):
http://www.cnblogs.com/me-sa/archive/2008/05/16/1200329.html%09http://www.cnblogs.com/JimmyZhang/archive/ 2007/12/20/1006555.html%09 ...
When these URLs are accessed, IIS returns the error of the "Bad Request":
Bad
request-invalid URL
HTTP Error 400. The request URL is invalid.
This error page is returned directly by IIS's underlying HTTP. SYS, and neither the error page nor the URL rewrite can be customized. The result is that when you visit such a URL, you can automatically jump to the correct URL (minus the End tab).
So I want to use the IIS URL Rewrite module to implement, but now the request is directly intercepted by HTTP. Sys at the bottom, can not reach the URL Rewrite module. Fortunately, the registry setting allows HTTP. sys to not intercept such URLs.
The registry setting method is as follows:
- Regedit open Registry Editor and enter Hkey_local_machine\system\currentcontrolset\services\http\parameters
- Add key value: Allowrestrictedchars REG_DWORD 1 (default is 0, will intercept \x00-\x1f and \x7f-\x9f characters, tab ASCII is \x09)
- Restart HTTP. sys and IIS so that the registry settings take effect:
net stop httpnet start Httpiisreset
When this is set, a request with a tab in the URL can reach the IIS URL Rewrite Module and redirect The jump with a URL rewrite rule. The result is that it doesn't work at all, and it's still a 400 error without jumping, but it's now returned by ASP.
HTTP Error 400.0-bad Request
ASP. Detected invalid characters in the URL.
This estimate is a small bug in the URL Rewrite module.
Later, a compromise solution was adopted, not redirect jumps, only URL rewrite, so that although the URL is not correct, but at least the page can be accessed normally.
Finally, the following URL rewrite rules were used to resolve the problem:
<Rulename= "Endwith_tab"stopprocessing= "true"> <MatchURL="^([^.] +\. (?: html|aspx)) [\x09] " /> <conditionslogicalgrouping= "MatchAll"Trackallcaptures= "false" /> <Actiontype= "Rewrite"URL= "{r:1}"appendquerystring= "false" /></Rule>
Resources
HTTP. sys registry settings for Windows
Use of special characters like '% ', ' and ': ' In an IIS URL
IIS problem Resolution: Bad Request-invalid URL caused by tab in URL