Mixed case URIs and IIS issues
Mixed case URIs and IIS issuesI have seen a couple of articles and forum threads where the case sensitivity of Internet search engines are creating issues with websites that are hosted on MS Windows using the Internet Information Service (IIS).
The fundamental problem is that the Windows OS is NOT case sensitive whereas Unix and the many Linux variants are. Consequently search engines such as Google, Yahoo!, msn etc have to be case insensitive to be able to deal with ALL manner of filenames.
For those who don't know, case sensitivity in filenames is where Default.asp, default.ASP, default.asp or deFault.asP would all be treated as different and independent files each capable of delivering different content. With web servers (IIS or Apache) running on a Windows OS all of the above would serve out the same file. This can lead to duplicate content issues (NOT a penalty Duplicate Content, The Myth) if SEs find a link to one of the mixed case variants and index it. With *nix if the page did not physically exist a HTTP 404 response would be raised (Page Not Found) and the indexing issue would simply not exist, but with Windows, provided the requested name matched a document, the content of that document would be served out along with a HTTP 200 response (Ok).
The fix, should this become a problem is fairly simple, and that is to stop mixed case file names ever being served out should a HTTP request contain an uppercase letter. All that is needed is a simple bit of code that can be included into the top of every document or, if your pages are created dynamically include it into the script that extracts the data and displays it.
ASP Code :: Set Lowercase URI
Click in the text to select the asp code
dim RequestURI
dim HostName
dim objRE
dim temp
RequestURI = _
request.servervariables("PATH_INFO")
HostName = request.servervariables("HTTP_HOST")
set _
objRE=new RegExp
objRE.global=true
objRE.pattern="[A-Z]+"
temp = objRE.test(RequestURI)
set _
objRE = nothing
if temp then
response.status = "301 Moved Permanently"
response.addheader _
"Location", "http://" & lcase(HostName) & lcase(RequestURI)
response.end
end if
The code simply uses a regular expression to check if there are uppercase characters in the script path and if so, converts the path to all lowercase and sends a HTTP 301 response (Moved Permanently) along with Location header for the lowercase URI.
This article was added by Chris Hirst and was posted on 18 November 2008. Chris has been a member since 09 January 2008 and has written 36 article(s) for modTalk
So long, and thanks for all the fish.
No comments as yet
Be the first to add a comment
Your email will not be shown
Your Name
Comment Title
Comment Text
Page Tags
No Tags to show