iFinity Blogs 

How to 301 Redirect .asp Urls to DotNetNuke .aspx pages

Aug 24

Written by:
Tuesday, August 24, 2010 1:48 PM  RssIcon

One of the most visited entries on this blog is How to 301 redirect .htm or .html Urls to DotNetNuke pages.  From that post, I get a lot of enquiries how to do this with .asp Urls.  I have usually just told people to substitute the .htm in the post with .asp, but I’ve decided to dedicate another post just to the task of converting/redirecting ‘Classic’ ASP urls over to a DotNetNuke website.  It would seem a lot of people are replacing old ASP websites with a DotNetNuke based system (a good choice!) so this should be the final word in keeping them pointed in the right direction.

So without further discussion, let’s get straight into the steps.

Step 0 : Backup

You’ll be (probably) be making changes to your web.config file, and it’s possible to mess up your entire site with a misplaced punctuation mark.  Take a copy of that file now and thank yourself later.  You can always delete a backup but you can’t conjure one back from the dead.

Step 1 : Install Ur l Master Module

You’ll need the Url Master module.   Any other way of doing it will be difficult and involve lots of dealing with IIS redirects and messing about.  Download the software from the Url Master Product Page.  If you’re new to this software, then you can get a free trial here.  It costs nothing to install and trial, and if it works (which it will!) then you can purchase later after you’ve solved your problem.  Just obtain the install package, load it into DotNetNuke via the module installer, and move onto step 2.

Step 2 : List out all your redirects

Chances are you’ve come to this situation either having already converted over your site, and wondered where your traffic went, or you’re in the planning stages of moving over your site, and can’t figure out the best way to transition your search engine rankings.  What you want to do is find out all of the Urls indexed for your existing site and put them into something like a text file or spreadsheet.

It’s unlikely you’ll be able to guess all of the various Urls so I suggest that you go to search engines and ask them for a list of all the Urls they’ve found on the site.  Nowadays with webmaster consoles you can often download a list of indexed Urls – this is a good way to go.  You can also use the site:www.example.com search syntax on Google and other search engines like Yahoo and Bing.    This list, when complete, is a list of all the Urls your old site has used.  This is the list of Urls you want to redirect from.

Next up is the list of Urls you want to redirect to.  This is the list of pages in your DotNetNuke site.   I don’t recommend just sending everything to the home page – you’ll get a much better long term result if you send all the product Urls to your product page, or all your ‘about’ type Urls to your ‘about’ page, and so on.  It doesn’t matter if you have 15 redirects all going to one page, just as long as you have a new home for each of your existing Urls.

Step 3 : Map the .asp extension to ASP.NET

This is the most important part of the process, and can’t be skipped or worked around.  You have to do it or the whole thing will not work.  In my experience helping people with .html redirects from the original blog post, the number 1,2 and 3 reason why they couldn’t get it to work is because they didn’t setup the correct mapping on their web server. 

If you’re a little unsure about what this is, let me give you a little background on what Url extensions are all about.  The Url extension works in the same way as a normal file extension, which associates a particular file with a particular program.  This is why when you click on a .xls file, it knows how to load Excel. 

Similarly, with a web server, using extensions on the Urls allows many different types of program to be installed on the one web server, and the server knows which program to run with which Url by looking at the extension.  Originally web servers were just like file servers that you could access from another place, but they have since grown to run programs (like DotNetNuke) requested from somewhere else.

By default, DotNetNuke runs with an extension of .aspx.  Thus, any default installation, the .aspx extension will run the ASP.NET application, which will then run DotNetNuke.  The .asp extension was used with 'Classic' ASP (Active Server Pages).  In fact .aspx was used to allow 'old' ASP applications to run alongside 'new' ASP.NET applications.  The .aspx extension was used to denote 'ASP+', which is what ASP.NET was going to be called before someone in marketing had a change of mind.  You couldn't use a + in an extension, so it got rotated to become 'x', hence we have .aspx instead of .asp+.  Incidentally this is where we get C# - it was to be C+++ - until some genius decided to add another + and turn it into a #.  The end result is that .asp is designed to run an entirely different program than .aspx.

In order to get the .asp Urls to work with ASP.NET, we have to tell IIS (the webserver) to no longer send .asp requests to Classic ASP, but to instead send them to ASP.NET, which is what DotNetNuke runs on.

Associating .asp Urls with the ASP.NET runtime

By default, any IIS webserver will be setup to associate .asp with the 'classic' ASP runtime.  In order to get a particular site (or application, depending on your IIS version) to work with .asp, the default configuration will need to be changed.  The instructions vary for IIS version.

NOTE : Before doing any of these instructions, be sure to take a full backup of at least your web.config file, if not the entire site.

IIS6

IIS 6.0 - Windows 2003 Server

  • open property page for website / virtual directory.
  • click the 'home directory' tab
  • click the 'configuration' button, select the 'mappings' tab
  • locate the .asp Extension entry
  • Click on 'Edit'
  • Change the executable value by browsing to the aspnet_isapi.dll (normally at c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll)
  • Ensure that 'check that file exists' is unchecked
  • Click OK, OK, OK to close and apply changes

IIS7 – Windows Server 2008 (and later)

IIS7 is different from IIS6 in that you can make changes to the handler mappings through either the user interface, or through the web.config directly.  In this case the example will be given to make changes to the web.config file, as this is faster and many people on shared hosting don't have access to the administration console.

You will also need to know whether your site is running on a 64 bit server, or a 32 bit server, though you can just enter both settings and let the server work out which one is correct for it.  Note that for these changes, it's not important if you're using IIS7 Classic or Integrated Pipeline mode.

To associate the .asp extension, you have to create a new handler entry for *.asp.  This is done by opening up the web.config file and adding this entry at the bottom of the existing list of entries in the <system.webserver><handlers> section.

For a 32 bit server:

<add name="classic asp" path="*.asp" verb="GET" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="4194304" />

For a 64 bit server:

<add name="classic asp 64" path="*.asp" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />

Note that if you don't know if you're on 32 bit or 64 bit, you can add both entries – the correct one will be used and the incorrect one will be ignored.

Step 4 : Add the redirects into the Url Master module

Now that the .asp extension has been mapped to DotNetNuke, any of the redirects requested will be processed by the ASP.NET runtime.

The final step is to add in the redirects to the Url Master module.  This is done via the Admin->Portal Urls page.

 

url-master-asp-301-redirect

 

The above image shows the detail of the page list.  Select the page you want to redirect to, and click on the ‘Add New Url’ button.  Enter the Url (without domain) into the field, and select the ‘http action’ to ‘301 Perm Redirect’.  Note you need to include the .asp extension.  The Culture is unimportant even if you have a multi-language site because the redirect will go to the default language of the page. 

Click ‘Apply Changes’ when you are finished.

Step 5 : Testing Changes

The first place to test is within the ‘Test Url Changes’ section of the Portal Urls page.  Just click on this section, and enter the Url you wish to redirect into this area:

url-master-create-301-redirect-asp

Click on the ‘Show Rewriting result with current settings’ button, and you’ll see results similar to above.

This shows that the Url will be redirected to the /forum.aspx Url.

Once this shows the correct result, then try the actual Url with your browser.  You should see the Url change and end up on the expected page.

Bonus section : Using an .asp extension page for your site

301 Redirects are the published way in which to transition a Url from one form to another, and are recommended for use by the major search engines.   I use them all the time to massage and fiddle with Urls, looking for the best Url for a particular page.

With that said, plenty of SEO experts maintain that you should avoid changing the Url at all costs, and I’ve no reason to disbelieve this advice.  If you have a high ranking Url for a high value competitive keyword and your business depends on that (or those) Urls, it’s probably a good idea not to rock the boat.  Unless you’re in that category (and by definition, 99% of us won’t be) then I would suggest you change your DotNetNuke site to work with the old Url, rather than forwarding the Url to your DotNetNuke page.

The process for doing this is exactly the same as the redirect, except you select ‘200 – OK’ as the Http Status of your new Url.  However, if you have a site using .aspx as it’s default extension (see Portal Settings section in the Portal Urls page) then you’ll end up with /forum.asp.aspx.  That’s because the extension is put onto the end of all Urls in the portal.  The solution is to move your site to no-extension Urls.  This will preserve your .asp extension, and will drop the .aspx for all other Urls in the site (301 redirects will handle this change for the other Urls).  You can, of course, choose to switch off the Url extension for the portal, and then go back in and add the extension back for all the Urls.  Or, you can change the portal Url extension to be .asp for all Urls. 

Final Thoughts

The ability to move from one web platform to another with your site is crucial, yet it gets overlooked by many platforms, or given token tools that only experts can work out, such as a bunch of redirect patterns using Regex patterns.  I’m an expert in Regex and I find it tedious and difficult to work with them, because it’s so easy to make a mistake.  It’s simply unthinkable that someone without a deep knowledge in this arcane field could even begin to do anything more than copy/paste and hope for the best.  

The steps posted here should be easily followed by anyone with a website, particularly if they are on IIS7, because they don’t even need the help of whomever looks after their hosting.

If you’re reading this post but not using DotNetNuke (and therefore Url Master) don’t despair, at least 50% of the steps apply to you.  You’ll just have to write a Http Module which will identify the .asp requests and have some type of process to identify how to send them off to their correct destination.   The simplest case is a large ‘case’ statement, the more complicated involves database tables and lookup values.

This blog post was written with regards to Url Master 2.01.  Earlier versions of the module work in the same way, and later versions will work in the same way, but some of the screenshots/terminology might be slightly different.  It won’t be hard to work out the difference.

Tags:
Categories:
Location: Blogs Parent Separator Crafty Code

2 comment(s) so far...


Gravatar

Re: How to 301 Redirect .asp Urls to DotNetNuke .aspx pages

Hi Bruce,

Great post! This is what i"m trying to do for a client right now, but I have a few issues. The biggest being that I am not in control or nor do I have access to the iis settings. Because of my hosting situation that is the case. I realize that may need to change in order to get what i need. Maybe not though.

I'm familiar with the url rewriter (great tool!), and I am trying to not lose old urls digested from the previous site to the new site.

The new site is here: www.avonbakeryanddeli.com

The previous site was done in asp and all urls are something like this: www.avonbakeryanddeli.com/asp/default.asp?p=2

It
was my understanding that I could just add the above link as a rewrite, list a 301 direct and be good to go. I'm finding that is not the case. when I add it it gives the message of:

Encoded Url Result
When used in a browser address bar, the Url you have entered will be encoded to remove characters which are not valid for the Url standard. The resulting text below is how your Url will look in the browser address bar when a user follows a link for this Url.http://www.avonbakeryanddeli.com/asp/default.asp%3fp%3d2

The goal was to get each digested link to the new and relevant page ie www.avonbakeryanddeli.com/asp/default.asp?p=2 needs to go to the about page.

Specifically is there a setting under the initial settings that I can somehow still get that url to a good page? I realize that it might not be the final specific page, but anything is better than page not found.

Any input would be greatly appreciated! Thanks, Mike.

By Resolution on   Saturday, September 04, 2010 6:12 AM
Gravatar

Re: How to 301 Redirect .asp Urls to DotNetNuke .aspx pages

@resolution : when all the old pages are querystring based like that, you need a custom set of rules to interpret the querystring and redirect to a specific DNN page. The Url Master module can only (at the moment) redirect based on the path of the Url, not on the querystring.

By Bruce Chapman on   Saturday, September 04, 2010 8:56 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel