Sitefinity Toolkit: Lowercase Url HttpModule

By in
No comments

One of the things that has always annoyed me about unix-based systems is the fact that they are case-sensitive. While I understand the need to differentiate between the two, and the advantages it CAN bring, in my opinion, it’s just not worth the hassle.

Since Windows servers ignore the case of requests, it should theoretically simplify things. Unfortunately, since people linking to your page might use any combination of upper-case and lower-case letters, it results in multiple urls to the same page being indexed in search engines.

Now I don’t know enough about SEO to know exactly how big a deal this is, but I do know that it is annoying to be viewing a link report and seeing 15 copies of the same page with a dozen different capitalizations. The easiest solution I found was to just force them ALL to be lower-case. That way anything that isn’t will be 301 redirected to the lower-case url and only that one will ever be indexed.

This was actually an easy thing to implement. Without going into to much detail, the basic idea is to intercept the url request and compare it against the lower-case version of itself using ToLower(). If they match, then we’re good to go. Otherwise simply redirect to the lowered url. Simple!

Installation

This is a no-brainer; simply put the following in your web.config:

<httpModules> <add name="LowerCaseUrl" type="SelArom.Net.Sitefinity.HttpModules.LowerCaseUrlModule" /></httpModules>

If you’re using IIS 7 be sure and add this to system.webserver as well:

<modules> <add name="LowerCaseUrl" type="SelArom.Net.Sitefinity.HttpModules.LowerCaseUrlModule" /></modules>

That’s all that’s required to get this working. To test it out, simply change any letter in the url for this page to uppercase and see how you are automatically redirected to the lowercase version.

Note: This module is designed only to intercept pages, that is urls to .aspx pages. If your site is using another extension, or is using extension-less urls, this module will most likely not work. If this applies to you, please email me your experiences so that I can include support for your setup in a future release.

Next time, I’ll be going over the Smooth-Menu feature of the toolkit, which automatically generates a simple, ul-li based navigation menu from your sitefinity sitemap. Until then, send me any comments, bugs or suggestions to josh@selarom.com. And as always, if you enjoy my work, please consider donating your support to expand my studio by using the widget on the sidebar.

The following two tabs change content below.

selaromdotnet

Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.