Tell Us About Your Business

Your name:
Business name:
E-mail address:
Phone number:
Comments or questions:
Subscribe to our newsletter:
Tickets |  Project Management |  207-347-7360

Search

Popular Tags

Archive

About Dirigo

Dirigo's roots are in retail, catalog, television and radio direct response marketing. We're responsible for multi-million dollar web businesses. Whether its sharing our experience and expertise or helping connect you to some of the best thinkers in our industry, we dig deep to find opportunities that drive revenue.

301-redirect .html pages to .aspx pages when migrating static website into .NET hosted under IIS6

August 16 / Ivan Sokolovich, Sr. Tech

301 redirects are very important for SEO when moving website pages to new locations. They are easy to implement when you switch from one scripting language to the other (i.e. from .asp to .aspx or from .php to .asp). All you need to do in this case is keep the legacy pages in your website and put 301 redirect code in them.

The problem comes in when you are trying to convert static .html or .htm website into .aspx. HTML file can't execute any code thus create a major challenge for implementing 301's.

Here's the proposed solution:

Right-click your website in IIS6 and select "Properties". Click on the "Home Directory" tab:

IIS6 Properties Home Directory

Now click on the "Configuration" button.

Application Configuration
Click "Add" button and add ISAPI mapping for .html extension so that aspnet_isapi.dll handles all html requests. If you don't want to keep old .html files in the new website make sure you uncheck "Verify that file exists" checkbox.

Add ISAPI mapping

Now every request for .html page will go through asp.net managed pipeline.

Add the following code to the Application_BeginRequest method of the Global.asax file in your new .NET website:

Application_BeginRequest

The code checks if the incoming request is for .html page and in that case creates a 301 redirect to .aspx page with the same name. If the names of the new .aspx pages are different from .html names, you can define those mappings in XML file or in database table and lookup new URLs that way. For the purpose of this article I kept the example really simple.