iFinity Blogs 

How To : 301 Redirect .htm or .html pages to DotNetNuke .aspx pages

by Bruce Chapman on Wednesday, June 24, 2009 10:01 PM

This is becoming a very common help request for me lately, as increasing numbers of people convert old html (and asp and php) based websites into DotNetNuke based websites to take advantage of the extra power of the DNN framework.  The problem occurs that many Html based websites have been around a long time and generally rank well in search indexes.  Typically, the site owner wants to make sure that none of that existing ranking and associated traffic is lost when converting to a new DotNetNuke site.

This post will cover all of the steps necessary to divert traffic away from an old html based website to a new, DotNetNuke based website.  If you have an old .asp or .php based website, the instructions are virtually the same with just the file extensions changed.

0. Do your backups.

You're going to be modifying the web.config file, so take a backup of this file before you start.  If you mess it up, getting it all back will be as simple as restoring your previous web.config file.

1. Install the Url Master software

You can download and install the software from the Url Master Product Page : it's free to trial, and if you are working on a live website, you can get a free trial licence to use on your live site.

Install the Url Master software as per the instructions.  Of course, this is going to change your site to use Friendly Urls, but if you're interested in maintaining your existing links, then you'll at least want to make sure they are supported, and this means friendly urls!   That's assuming you didn't name your existing .html files "tabid-123-ctl-view-display.htm" instead of "product-information.html" like a sane person.

2. Plan your redirects

If you have a series of .html files 'out there' indexed, bookmarked and generally known by people on the internet, you're going to want to capture those and '301' redirect them to somewhere else, should they be requested.  This does two things : by using a 301 redirect, you will update the Search Engine indexes to your new locations, and any users using an old link from a bookmark or other website will still end up where you want them to be.

However, if you're going to move away from existing known urls to new ones, you need to plan which ones to capture.  The easiest way to do this is to do a search in search engines for indexed pages.  A simple site:domain.com search in Google will turn up the majority of indexed links.  You can also go back through your site logs using an log analyser, or do a site search in Yahoo.  You may also be able to get a list of Urls from a webmaster console in Yahoo or Google.  This is the list of Urls you will redirect from.

Once you have a list of all the urls you need to capture and redirect, you need to have the new Urls to send them to.  It's often tempting to just redirect everything to the home page of your new site, but if you can, plan your new site so that it has logical places to send the old urls.  You should have at least rough categories like products -> new product page, contact -> new contact page, etc.

Make sure these new Urls are created in DNN so you can see the Urls you'll redirect to.

3. Map the relevant file extension to ASP.NET

This is the important part.  A little background : the extension on a request to your IIS webserver allows IIS to determine which piece of software installed on the webserver should handle the request.  If you request a .htm file, then IIS knows what to do with it : it just streams the file back out to the browser as is by reading it from the file system and sending it back out.  Same thing for Jpeg or Gif files : it sets the media type of the response, and then streams the binary image information back to the browser.  So far so good.  When your IIS server receives a response with the .aspx extension, it knows that it must pass that response to the ASP.NET software (called the ASP.NET runtime) installed on the server.  ASP.NET then handles the interpretation of the code within your .aspx file, and gives the results back to IIS, which ten steams them back to the requesting browser.  

There's nothing magic about the .aspx extension : Microsoft just decided on this because the previous generation of ASP used the .asp extension, and it needed a new one.  So they decided on .aspx and the rest is internet history.  The same principle applies to .axd, .ashx and all the other ASP.NET specific extensions.  All they do is inform IIS to pass the request along to ASP.NET for processing.

Now, DNN is just a program built using ASP.NET technology, so each and every request for DNN must be associated with the ASP.NET runtime files.  This is why the standard DNN Urls all end with /default.aspx : so that IIS knows that ASP.NET must be used to handle the request.

When you install the Url Master software, it gets run for each and every request that is handled by ASP.NET, and, by association, DotNetNuke.  If that sounds concerning to you, don't be worried, because the Url Master software has an efficient regex filter to ignore the requests it doesn't need to intercept.

Now, in order for the Url Master software to redirect your old .htm request to your new DNN page, it needs to know when that .htm request is made.  This is done by mapping the .htm extension to the ASP.NET runtime, so it behaves in just the same way as a .aspx page.

Concerned? You needn't be.  Although you can serve up html pages using the ASP.NET runtime, you won't even be doing that.  All that will be happening is that the .htm request will be intercepted by the Url Master software, it will decide where it should be redirected to, and the redirect will take place.  The whole redirect process is lightning fast.  And if you have a .htm page in your website that isn't a DNN url, then asp.net will just process it in the same way that IIS does - you, your server or your visitors won't be able to tell the difference.

Here's how you do that mapping:

IIS6

Go to your IIS Management page.

  • open the property page for website / virtual directory.
  • click the 'home directory' tab
  • click the 'configuration' button, select the 'mappings' tab
  • click 'Add' under the 'Application Extensions' list to add a new application extension mapping
  • browse 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 Classic Mode / Integrated Pipeline mode

In IIS7 you can change the configuration in the web.config file, which saves having to mess about with the IIS user interface.  This is also very useful if your host doesn't give you direct access to your IIS interface.

What you need to do is specify a new handler for the .htm extension.  The entries below are separate : one for classic mode, one for integrated mode.  It's best just to enter both, in case you don't know if you're using classic or integrated, or if you decided to switch in the future.  However, you will need to choose the correct combination of both Windows 32 vs 64 bit, and ASP.NET version 2 or 4.  If you don't know, find out before adding these entries.  You should be able to tell from the other entries in the <handlers>section, however.</handlers>




Settings for associating .html files with asp.net


32 Bit Version ASP.NET 2.0



<system.webserver>
 <handlers>
  <!-- classic mode .htm handler to make asp.net handle .htm requests -->
  <add scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" name="HtmlHandler-Classic-32" />
  <!-- integrated pipeline mode handler to make asp.net handle .htm requests -->&l<add type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="ManagedPipelineHandler" name="HtmlHandler-Integrated-32"/>
</handlers>
</system.webserver>



64 Bit Version ASP.NET 2.0



<system.webserver>
 <handlers>
 <add scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness64" path="*.htm" verb="GET,HEAD,POST,DEBUG" name="HtmlHandler-Classic-64"/>
 </handlers>
</system.webserver>



32 Bit Version ASP.NET 4.0



<system.webserver>
 <handlers>
  <!-- classic mode .htm handler to make asp.net handle .htm requests -->
  <add scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" name="HtmlHandler-Classic-32"/>
  <!-- integrated pipeline mode handler to make asp.net handle .htm requests -->
  <add type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="ManagedPipelineHandler" name="HtmlHandler-Integrated"/>
 </handlers>
</system.webserver>



64 Bit Version ASP.NET 4.0



<system.webserver>
 <handlers>
  <!-- classic mode .htm handler to make asp.net handle .htm requests -->
  <add scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" name="HtmlHandler-Classic"/>
  <!-- integrated pipeline mode handler to make asp.net handle .htm requests --><add type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="ManagedPipelineHandler" name="HtmlHandler-Integrated"/>
</handlers>
</system.webserver>


These two entries inform IIS7 to run the related asp.net runtime when a .htm request is received.

Note that you should add these to the end of the section, after all the other handlers that are defined for the site.

Configure ASP.NET to process .htm files


As previously mentioned, if you do have .htm files in your web application, then they are going to be processed by ASP.NET.  That's no problem, but you do need to let the ASP.NET runtime know about it. 


IIS6 / IIS7


First, tell ASP.NET how to handle .htm files by adding in a Http Handler

<system.web>
 <httphandlers>    
   <add type="System.Web.UI.PageHandlerFactory" path="*.htm" verb="*"/>
</httphandlers>
</system.web>

Next, tell ASP.NET how to build a .htm file.  Note that nothing actually changes as there is no code in the file, but it still needs to be run through the build process.

<system.web>
<compilation>
<buildproviders>     
<add type="System.Web.Compilation.PageBuildProvider" extension=".htm"/>
</buildproviders>
</compilation>
</system.web>



Remember that because the web.config file is an Xml file, all of this is case sensitive, so take care with all of your entries.

5.  Configure the Url Master software to stop ignoring .htm files.

This is done by going to the  'Regex Settings' section, and changing the value in the 'ignoreRegex'.  What you need to do is carefully remove the section relating to the .htm extension : it will look something like this: |\.htm$

Note : this needs to be done in the Host->Friendly Url Settings page, as it needs to apply at the installation level.  If you do this at the Admin->Portal Urls level, it will still be blocked at the host level and you will continue to get a 404 error until the Host level regex settings are modified.

Once this is done, the Url Master software will inspect all of the .htm requests for rewriting and allow it to perform a redirect if necessary.   Note that any time the Url Master module finds a physical file on the server relating to a request, it performs no rewriting.  In other words, if /myfiles/myfile.htm exists on the server, then the software knows that it's not a virtual Url, and therefore leaves it alone to continue processing.

Note : A virtual Url is a url that doesn't correspond to an actual file on your server.  A virtual Url is a 'made up' Url that doesn't work unless there is some software interpreting what the Url means.  That's the reason a 404 Resource Not Found error is quite common if your Url Rewriting isn't configured correctly.

6.  Add in your .htm redirects in the Url Master User Interface

To do this, go to the Admin->Page Urls page that is created when the Url Master software is installed.  In order to setup a redirect, you need to work backwards.  That is, you select the page you would like to redirect to, and enter the Url you'd like to redirect from.

htm_aspx_301_redirect_add

Remember to click the 'apply changes' button when you're finished.

7. Test and Check your Results

There's two ways of testing your redirects.  The first is to go to the Friendly Url Settings page, and use the 'Test Url Rewriting' section.  Type in the full Url as you want redirected, and click the 'test' function.

Redirect_htm_aspx_test

The above example shows the test output for 'oldpage.htm', which redirects to the DNN page called 'New Page' at new-page.aspx.

Wrapping Up

These instructions actually contain the advice for another, related task.  You can run your DNN site on whatever extension you like : from .aspx, to .htm, even .php or .dnn!  There is no restriction on what the page extension is for your site.  If you want to run your entire DNN site on a different page extension, just change the page extension in the Friendly Url Settings page, and ensure all the above ASP.NET mapping is in place before you hit the 'Apply Changes' button.

I once read someone on an ASP.NET support forum lecturing another person for wanting to change away from .aspx : the lecture took the form of 'why would you want to even do that?'.  Well, there are many reasons not to run the .aspx extension for your DNN pages : backwards compatibility, obfuscation of technology, lots of reasons.

If you have other extensions that you need to redirect from, then you just follow the instructions as listed, replacing .htm with whatever extension you're working with.

Success Stories

If you've redirect an old site over to a new DNN site using the advice listed here, let us all know about it!  Just post your success stories in the comments.  I always get a kick out of seeing the code in action, solving what was once unsolvable problems!

NOTE: There are other, similar posts to this for other common type of redirects.  See:

Blogs Parent Separator Crafty Code
Author
Bruce Chapman

The craft of writing code. The outcomes from being crafty with code. Crafty Code is tales from the coding bench.

65 comment(s) so far...

Anonymous 6/23/2009

Great post Bruce and very timely, so if we need to redirect multiple page extensions (in IIS7) would each of the steps above require the addition of - path="*.htm,*.php" and extension=".htm,*.php" etc?<br><br>Cheers<br>

 
Bruce Chapman 6/23/2009

@adam : yes is the answer. You would need to repeat the steps in the configuration for each of the extensions you wish to intercept.

 
Anonymous 6/24/2009

Well, I tried it and I can not get it to work. I am on a shared hosting plan Wiindows Server 2008. I did the web.config changes and the other setup items you listed. When I test it using Friendly URl Setting they resolve correctly excep one case, /default.htm gives error 404. When I try to browse the old url , such as www.apropos-business.com/company.htm I get error 404.<br><br>I also have an old privacy/htm page but the DNN privacy page does not show up in the list to map the old url. How do I map to the privacy page?<br><br>Overall this looks like an excellent product and I just need to get the htm problems fixed.

 
Bruce Chapman 6/24/2009

@john it's hard to say without looking through all of your changes, but if the rest of your site is still working OK, then it's probably in the association of the .htm with the asp.net runtime. I would double check your settings and perhaps ask your host if they can check them for you as well. <br><br>Unfortunately you can't redirect to the privacy page because it's a special type of Url in DNN. However, if you map the .htm extension to your site properly, it may work out OK for you anyway. I haven't tried that myself, but I would expect it to work.

 
Anonymous 7/21/2009

What will happen if the file does not exist and the request is not being processed by URL Master?<br><br>Example: I set up the host to give 404s to any file and file extension that doesn't exist. So if oldpage.htm doesn't exist on the server, the host redirects it to my 404 page before URL Master has a chance to process the request. Can I have it both ways were it will 301 redirect "oldpage.htm" and 404 "doesntexist.htm"?

 
Bruce Chapman 7/22/2009

@erik if the page doesn't exist and there is no physical htm file, you'll get a 404 error for 'doesntexist.htm'. However, you would need to set up your host so that virtual urls on the .htm extension are allowed through.

 
Anonymous 7/30/2009

We recently moved our old website to DNN and had dozens of old html and shtml files. I've got them all 301 redirecting to our new DNN pages (with no file extension, by the way) and it's marvelous. Everyone's old bookmarks still work, old links still work - it's great.

 
browe68 8/29/2009

Hey Bruce,<br><br>I tried to do this and here is what happened....<br><br>1) I made the changes to the web.config file and uploaded it. Then, went into URL Master and did the test on the .php pages. All test came back with the URL redirects that I was looking for. So, this seemed to work just fine. (at least it appeared to).<br><br>2) I am in a shared hosted environment with PowerDNN on IIS 6.0. When I had PowerDNN support make the appropriate changes above, all pages in my site that had an extension (all are .aspx) came back with the error - "The system cannot find the file specified. " <br><br>So, I had them change it back until I could troubleshoot further.<br><br>I think that I am close, but am missing something.<br><br>Any suggestions.<br><br><br>Thanks.

 
Anonymous 11/12/2009

Hi, after I used added your tags lines to the Web.config for HTML pages, my aspnet_isapi works GREAT for HTML document.<br><br>But when I used the same method (above) on .JPG and .gif extension, it displayed a whole page of unrecognized symbols instead of graphics. <br><br>Although it sounds weird, I do need aspnet_isapi.dll for all my forms (.jpg, .gif, .exe, .doc) because I have a httpModule running before them to handle the BeforeRequest event to check the users who they are before displaying the pages(.aspx)/documents(non .aspx)!!<br><br>Is "System.Web.Compilation.PageBuildProvider" and "System.Web.UI.PageHandlerFactory" OK for anything including .exe, .JPEG and .gif ? Why doesn't your method work? Is something to do with MIME type?<br><br>Thanks,<br>L.<br><br>

 
Anonymous 11/13/2009

@lena : I haven't tried doing this for other MIME types, but I'm guessing that's what the problem is. If you're getting the byte content of the file delivered as text (which is what funny symbols on apage is) then it's likely to be the MIME type. I'd have to research this to say for sure.

 
Anonymous 11/13/2009

Bruce : Just another thing (could be a hint to my question above, never know!) to tell you is <br>When I test all my security modules for BeginRequest on my localhost (the workstation server that comes with Visual Studio 2008), everything works SURPRISINGLY fine WITHOUT mapping of any type like I have to do for the public server. On localHost, right after executing of the httpModule, the context immediately return to the display of TEXT (if .txt) and graphics (if .gif/.jpg/.wmf) ! And I didn't do a thing to make it happen on localhost. <br><br>Do you think localhost has something that the real IIS 6 does not have?<br> <br>(I'm almost tempted to install Visual Studio 2008 on that machine!)<br>L. <br>

 
Anonymous 11/13/2009

Referring to the previous problem, my Workstation is Windows XP v5.1 (Service Pack 2) and the Web Server is Windows Server 2003 v5.2 R2 (service pack 2) -- they are both using aspnet_isapi.dll of v2.0.50727

 
Anonymous 11/13/2009

@lena localhost is just the dns address of an IIS server - that makes no difference. I would say it is a configuration difference between your two servers (workstation and server) that is causing the difference, rather than something different in the software.

 
Anonymous 11/18/2009

Bruce:Thank-you for your response!Still a mystery why my PC's localHost doesn't need any aspnet_isapi config, but the Windows 2003 server (the WebServer) does. However, after a long battle, I decide to write my own handler and it works! <br>L.

 
Anonymous 2/6/2010

Can you tell me how to do the opposite. I'm trying to retain all my good search engine ranking on an aspx site that has been redesigned into htm. Please help.

 
Anonymous 2/6/2010

@Lenora : this advice is for users of DotNetNuke. If you've switched to using a .html site you'll need to setup 301 redirects for all of your Urls. You'll need to find out how to do this with the new technology you're using.

 
Anonymous 4/19/2010

Hi Bruce, first of all I want to thank you for the awesome support you are providing to your customers, plus you always respond really quickly. <br>Your post is great but there is one thing I'm not sure to understand: Point 4 of your post: Configure ASP.NET to process .htm files -> I assume we add that code in the web.config also. Correct? Next, the 1st person who replied to your post asked you about multiple extensions mapping... doing "path="*.htm,*.php" and extension=".htm,*.php" etc?<br>" but you answer isn't clear to me.. Thats the correct way to do it or we need to do it with separate line? Would you be nice enough to type the code for adding .htm, .php and .swf for example to make sure I get it right?<br><br>Thanks again,<br>

 
Bruce Chapman 4/19/2010

@pat you need a separate line for each extension:<br> [add verb="*" path="*.htm" type="System.Web.UI.PageHandlerFactory" /]<br> [add verb="*" path="*.php" type="System.Web.UI.PageHandlerFactory" /]<br>and the build providers:<br>[add extension=".htm" type="System.Web.Compilation.PageBuildProvider" /]<br>[add extension=".php" type="System.Web.Compilation.PageBuildProvider" /]<br><br>(note [] brackets should be )<br><br>

 
Anonymous 4/22/2010

Took some time but with the awesome support Bruce Chapman gave me, now most of my redirections are fully working. I might come back later with some little questions but UrlMaster is a module you don't wanna live without.<br><br>Thx Bruce

 
Bruce Chapman 4/22/2010

@pat glad you're up and running. Note in my previous comment it should say [] brackets should be greater than/less than signs. Commenting system eats Html/xml.

 
Anonymous 7/21/2010

I'll be moving from a website with pages referred to without any extension. <br>Example: <a href=" http://mywebsite.com/downloads/<br>Is" rel="nofollow">mywebsite.com/downloads/<br>Is</a> there a way to override the directory handler to send those requests to asp.net?

 
Anonymous 7/30/2010

Unfortunately mapping the mime type for the virtual files kills the physical files. The virtual files are handled by ifinity and work fine. The physical files return 404 because the PageHandlerFactory and the PageBuildProvider cannot process the htm or html files.<br><br>So it's all or nothing. You either have html files on your site, and cannot use ifinity to redirect some. Or you have no html files on your site, and you can use ifinity to redirect any virtual files.

 
Anonymous 7/30/2010

"Note that any time the Url Master module finds a physical file on the server relating to a request, it performs no rewriting." <br><br>I wish this were the case. Unfortunately, if a physical file exists with no redirect then a 404 error is generated. Remove URL Master and asp.net processes the page just fine.<br><br>Is there some hidden setting that could be causing this?

 
Bruce Chapman 7/30/2010

@Dan if you're getting a 404 on an actual file, then add the file name to either the 'ignoreRegex' or the 'doNotRewriteRegex' fields. You can just append the filename to the end like this: |filename\.aspx This will prevent the module from trying to rewrite the file.

 
Anonymous 8/25/2010

i am facing problem with popup..<br>i am using window.open method of jacascript to popup an aspx page.<br>i was working on dev site but not on production site...what would be the reason..<br>few thing think worth mention<br>1: i haven't included aspx page in custom module dnn file so i need to add popup.aspx manually it was not included in desktopmodule\MycustomModule folder.<br>2: this popup call have a querystring in it.<br>3: when user click on popup button request for popup.aspx get created like mydomain\desktopmodule\mycustommodule\popup.aspx?id=x<br>but within a second or two it changes to parent page url.<br>4: when i try to open popup page in browser directly on <a href="<br>http://mydomain\desktopmodule\mycustommodule\popup.aspx?id=x<br>it" rel="nofollow">mydomain\desktopmodule\mycustommodule\popup.aspx?id=x<br>it</a> redirects to parent page mydomain\tabidx\....<br><br>i think something i am missing big thing like your url writting architecture.<br>

 
Bruce Chapman 8/25/2010

@rusty : not sure of what your exact issue is there - feel free to download a trial copy and try out the software. If you can't get it to work the way you want post a question in the support forums.

 
Anonymous 8/26/2010

Hi Bruce and everyone - <br><br>I don't see anything on here explaining how to configure IIS5.x to work with URL Master. Is it possible? I am running IISv5.1 and I'm not having any luck with redirects, using localhost. Any advice please?

 
Bruce Chapman 8/26/2010

@jonathan yes, it will work OK with IIS 5. You just need to experiment with adding the script map to get the wildcard mapping right. See the Knowledge Base on this site for more info.

 
Anonymous 1/4/2011

Hi - We have about 500 HTML pages we want to redirect to individual pages in our DNN/Catalook site. How can we do this with Infinity? Ideally, we would configure something analogous to a HTAccess file. (We are using IIS6) Please advise?<br><br>thanks,<br><br>steve

 
Bruce Chapman 1/4/2011

@stephen there is no htaccess equivalent. Please create a post in the support forum with your question, far too much to cover in a blog comment.

 
Anonymous 1/27/2011

how about redirect htm to html pages for php code, or using htaacess?<br>can you help me please?<br>RObert

 
Bruce Chapman 1/27/2011

@robert this blog focuses on IIS and ASP.NET, you'll have to find answers for php elsewhere

 
Anonymous 4/6/2011

Hi <br>I want to 301 redirect .shtml pages to .aspx , how can i do that <br>please help<br>Regards<br>

 
Anonymous 4/7/2011

Trying to set up handling of .htm and .html files on our staging server, in preparation for set up on live server. We are running IIS version 6 and I think I have followed all of the instructions correctly. I have added: <a href=" http://www2.logrhythm.com/index.htm" rel="nofollow">www2.logrhythm.com/index.htm</a> ti Ifinity after following all of the instructions in this BLOG post, but I'm getting the following error.<br><br>======<br>Server Error in '/' Application.<br>The resource cannot be found.<br>Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.<br><br>Requested URL: /404.aspx<br><br>======<br><br>Can you share some insight as to what might be going wrong.<br><br>Thanks in advance, Andy.

 
Bruce Chapman 4/8/2011

@browe check to make sure they didn't tick the box for 'ensure file exists' - or whatever it says depending on exact IIS version.

 
Anonymous 9/19/2011

Does Anybody know where i can find more info on SEO?<br />Please Bruce give me an help.<br />Best Regards<br />Max

 
Bruce Chapman 9/19/2011

Max - there is a lot of information to absorb with SEO. I would suggest first doing some basic research into SEO with DotNetNuke - there are some good articles around. Once you have done that, you can move into more specific areas once you have identified where you would like to concentrate with your site.

 
Anonymous 11/4/2011

Hi there,<br />I'm having issues redirecting .htm pages. I've added the code to my web.config, and set up a redirect rule in Portal Urls, however when I put in xxx.htm I get taken to the 404 page I've specified in IIS7 Error Pages. <br />When I add .aspx to the URL (eg xxx.htm.aspx) the rule works fine, which suggests (as you've said in posts above) that it is to do with getting .NET to handle the request.<br />Would you have any advice?<br />Thanks<br />Clare Hodgkinson

 
Anonymous 11/6/2011

@clare just double-check your .htm mapping in IIS, and also check you have changed the 'ignoreREgex' pattern to exclude the .htm value in it (as stated in the post)

 
Anonymous 11/7/2011

Hi Bruce,<br /><br />Thanks for your email. I believe this is what the web.config code deals with, the .htm mappings: <add name="HtmlHandler-Classic-32" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule"... etc?<br /><br />On further investigation it looks like any URL I enter for redirection which does not have a .aspx extension (eg .htm or a URL without an extension) is having .aspx attached to the end (so xxx.htm.aspx works where .htm does not, and xxx.aspx works where xxx does not). I've checked the database and it's not being added there, so it must be after the value is retrieved from the database. I've also looked through all the settings but can't find anything that would appear to cause this.<br /><br />Any ideas?<br /><br />Thanks<br />Clare<br /><br />

 
Anonymous 11/7/2011

Sorry Bruce, I'd put a bit of code at the end of the first paragraph in my last post, but it seems to have been removed on posting. <br /><br />The code I added to web.config was to add HtmlHandler-Classic-32, HtmlHandler-Classic-64, HtmlHandler-Integrated-32 and HtmlHandler-Integrated-64 (all for path *.htm to associate with IsapiModule).<br /><br />Thanks<br />Clare

 
Bruce Chapman 11/8/2011

@clare can you please post an issue in the support forums to follow this up. The html mapping won't change the way the redirect works - all it does is ensure that IIS passes the request along to the correct module.

 
Anonymous 11/22/2011

Works as expected thanks Bruce

 
Anonymous 1/27/2012

I did the following changes and now my .htm pages are going through but they are landing on my 404 error page. These are pages that do not exist on my site, but virtual pages that i have added to the infinity url custom url redirect. In previous comments, I saw that it was stated that if these are virtial urls, i would need to set up the host to allow virtual urls to go through. How do we do that. Is it inside dnn or infinity. Would love some feed back. thanks in advance

 
Bruce Chapman 1/27/2012

@franco if you have added in redirects, please test them out in the Url Master test section first. If they are working there, you can look for the problem in the IIS mapping. If they aren't working there, the problem is within the Url Master configuration. The virtual Urls will go through to the Url Master handling as long as the .htm/.html is not in the 'ignoreRegex' pattern.

 
Anonymous 2/19/2012

Tip: the HTML file you are re-directing must not exist in the Website, otherwise URL Master will not re-direct.<br /><br />Ex: If you want to re-direct "old_page.html" to "new_page.aspx", then "old_page.html" must not be present in the folder.

 
Bruce Chapman 2/20/2012

@Pierre - yes, this is a very good point I totally skipped over. The Url Master module prioritizes 'physical' files on the server, so only will process redirects if the equivalent filename doesn't exist. So if you're redirecting content to dnn pages, then you'll need to remove the old content to ensure the redirects work OK.

 
FrancoBao 3/15/2012

@Bruce - I have done the test inside the Master Url and I think that it is right inside the test. Am I suppose to get the right url with the link at the bottom after the redirect results. I am not sure what to do next.

 
Bruce Chapman 3/15/2012

@francobao if the test is working out OK, and you have set up the IIS changes, then you should try the Url to see if it redirects correctly.

 
FrancoBao 3/15/2012

@Bruce, when i try to run the url through the website, i get a 404 error page of to my custom error page on the site. What does that mean

 
FrancoBao 3/16/2012

@Bruce - I just went back and redid all the steps with web.config and I am still not getting the .htm page to redirect after setting it up on the hame page url master redirect setting. I don't know how to trouble shoot the stuff. I have been able to connect htm pages directly to custom folders where i have placed fake htm pages, that is not a problem for me to access.

 
Bruce Chapman 3/16/2012

@franco - please create a new thread in the support forum to try and troubleshoot the issue. The html file path to be redirected must not point to an existing html file.

 
Lee Rosner 4/13/2012

Our site is hosted on a shared web server with DNN4LESS. We are using ASP.NET 4.0 64 Bit. I added the "Configure ASP.NET to process .htm files" code from the above blog post to the web.config file and the web site went down with a "500 - Internal server error".<br /><br />Please advise.

 
Bruce Chapman 4/14/2012

@Lee just restore to your backup web.config and the problem will be resolved. Take a note of the actual error if it showing one, and/or see if you can find what the error was in either the DNN event log or windows event log. Most likely it is an error with copying the wrong section into the wrong part of the web.config file.

 
Anonymous 5/17/2012

I have an old website with the domain name spcgroup.org and the pages are html extensions. The group has changed their name so the new site is a DNN site with the domain name Communicatorsclub.org.<br /><br />Can I 301 redirect spcgroup.org/home.html to communictorsclub.org/home.aspx?<br /><br />please advise!

 
Bruce Chapman 5/17/2012

@Judy no problem - just add the old domain as a portal alias in the site, then set up the redirect to the home page as detailed in the blog post.

 
Anonymous 8/18/2012

Hi Bruce, <br /><br />Just to let you know that this worked. I only blew up the website once when I put the statement in the section when I didn't catch that it should go in the section. It really helped that I did each step, one at a time, and tested each step. When it did blow up, I knew which line was the problem line, then caught my error. <br /><br />I needed to redirect an old link from University of California Berkeley (www.uhs.berkeley.edu/facstaff/healthmatters/eatwellcatering.shtml#caterers - a very valuable link!) to a new page after we moved from an html site to a DNN 6 site (<a href="http://www.checkerscatering.com" rel="nofollow">www.checkerscatering.com</a>). <br /><br />Thanks so much for the detailed instructions.<br /><br />Best regards, <br />Tom

 
Josh 9/6/2012

I was having trouble getting this to work with redirecting old .htm pages to the new DNN pages with .aspx. The thing that I was missing in the web.config was having the attribute runAllManagedModulesForAllRequests added to the modules section under system.webServer. Once I set that attribute to true it started working. Here' what my node looks like, in case it helps someone else having trouble<br /><br />[system.webServer]<br />[modules runAllManagedModulesForAllRequests="true"]<br />... module entries....<br />[/modules]<br />[/system.webServer]<br /><br />The [] brackets would be replaced with less than/greater than respectively.

 
Bruce Chapman 9/7/2012

@Josh - yes, that is an option. Switching the 'rammfar' to true will map *all* extensions to the .net runtime, not just the .html ones. It may be the simplest way to achieve this.

 
Anonymous 9/11/2012

Hi, <br /><br />I trying the redirect page with *.html to existing page with in the instance but it was not working, it always redirect IIS Page not found. Could anyone let me know why?<br /><br />Best Regards,<br />Bunheng

 
Bruce Chapman 9/11/2012

@bunheng if you're seeing an IIS 404 page, it generally means you haven't mapped the .html extension to the asp.net runtime correctly. Check to make sure you copied the correct entries, and have identified the correct iis/asp.net combination.

 
Anonymous 11/8/2012

BTW, best possible articles on setting up DNN error handling and 404 or 302/301 redirects are here on the site from Bruce. I have had some of the basics for a while so that we were handling redirects to the 404 page for folders, jpgs and htm files, but when I needed to do a process and redirect of that htm by the asp.net page I knew I had to come here for the specifics and BAM, it's the next item listed in the Popular Blog Posts.<br /><br />Popular? of course, Bruce is a life saver!<br /><br />Thanks Bruce, as always, YOU ROCK

 
Anonymous 11/14/2012

Hi Bruce,<br />We went live today with our new DNN site (on IIS7 with no extensions) and with the iFinity.UrlMaster module doing some great work in keeping the URLs looking clean and understandable. All good so far. <br /><br />We then went straight to work on trying to hold on to some Google 'juice' from some of the old URLs (with .html) to the new website page urls (no extension). Trouble is we are getting 404 errors. We went through as much of the iFinity.UrlMaster module Support as we could understand - but can't get the 301 feature to work. It shows the redirects from the unfriendly redirects but despite following the instructions it does not show the 301 redirects we have added manually when we chack them in Friendly Url Settings. <br /><br />Please advise as we are desperate to hold the Google juice from the old site pages. <br />Thanks

 
Bruce Chapman 11/14/2012

@mark - please add a help desk ticket or support forum post so that I can help you with the issue. Make sure you supply the Urls that are and are not working so I can take a look at them. The first thing to always check is if the .html/.htm extensions are still in the 'ignoreRegex' pattern.

 
markegan 11/14/2012

Hi Bruce, mark - I submitted a ticket to the support forum and supplied the Urls that are and are not working. Also the .html/.htm extensions are still in the 'ignoreRegex' pattern. Any additional pointers would be great. Also could we pay you to dial in and trouble shoot?

Bruce Chapman
Hi, I'm Bruce Chapman, and this is my blog. You'll find lots of information here - my thoughts about business and the internet, technical information, things I'm working on and the odd strange post or two.
Connect with Bruce Chapman on Google+

Share this page
Get more!
Subscribe to the Mailing List
Email Address:
First Name:
Last Name:
You will be sent a confirmation upon subscription

Follow me on Twitter
Stack Exchange
profile for Bruce Chapman at Stack Overflow, Q&A for professional and enthusiast programmers
Klout Profile