301 for html pages instead of 404

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
6/4/2009 12:15:42 PM
Gravatar
Total Posts 58

301 for html pages instead of 404

If you have already solved this scenario with mojoPortal than I apologize.  I did a few searches and didn't find what I was looking for.  Is there a way to use the PageNotFound.aspx and the 301 feature to redirect old HTML files to new aspx locations.  I have a new site going online and the staging ip is http://207.250.211.213 pages like http://207.250.211.213/CM/Custom/home.html have been moved to http://207.250.211.213/home.aspx but I only get the 404 page.

Also, why is my 404 page not skinned like the rest of the site.  I haven't used these advanced features before so forgive my ignorance.

Best Regards,

Aaron

 

6/4/2009 12:21:17 PM
Gravatar
Total Posts 18439

Re: 301 for html pages instead of 404

Hi Aaron,

The only way it could work is if .NET is configured to handle requests for .html files, otherwise its IIS that will return a 404 and .NET code will not be involved in handling the request at all by default.

If using IIS 7 there are new free IIS modules that can be used to configure permanent 301 redirects. I think the new url rewriter can do that.

Hope it helps,

Joe

6/5/2009 3:05:26 PM
Gravatar
Total Posts 58

Re: 301 for html pages instead of 404

<system.webServer>
      <handlers>
            <add name="htm-aspnet" verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" />
      </handlers>
...

I added the above into my web.config and that is working well in testing so far for */*/*.html to *.aspx in the mojoPortal Redirect Manager.

The only problem is that I can't use CKEditor anymore and have to use TinyMCE.  I'm investigating the CKEditor issue.

6/5/2009 3:10:50 PM
Gravatar
Total Posts 58

Re: 301 for html pages instead of 404

I guess CKEditor uses an html file that I don't want ASP.NET to handle for me. Crap! Any ideas would be welcome.
 

2009-06-05 16:04:36,910 ERROR mojoPortal.Web.Global - 127.0.0.1-en-US - /ClientScript/fckeditor264/editor/fckeditor.html?InstanceName=ctl00_mainContent_edContentinnerEditor&Toolbar=FullWithTemplates
System.Web.HttpException: There is no build provider registered for the extension '.html'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
at System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown)
at System.Web.Compilation.BuildManager.....
 

6/6/2009 1:57:26 PM
Gravatar
Total Posts 18439

Re: 301 for html pages instead of 404

Hi Aaron,

Ask me about this again after the next release and I will tell you how you can configure it in IIS7 so that you could use the mojoPortal 301 redirect manager for this. I will also be writing an article after the next release about how to use extensionless urls in IIS 7. 

Best,

Joe

6/8/2009 8:25:39 AM
Gravatar
Total Posts 18439

Re: 301 for html pages instead of 404

In IIS 7, the 301 Redirect system in mojoPortal current release (2.3.0.4.b) "may" work for .html files if you edit the system.webServer modules section 

add the empty preConditon to the UrlRewriter module like this:

<add name="UrlRewriter" type="mojoPortal.Web.UrlRewriter, mojoPortal.Web" preCondition="" />

and add this attribute onto the <modules> element like this: <modules runAllManagedModulesForAllRequests="true">

It definitely works in the latest svn trunk so it will work in the next release.

Then you can create mappings under Admin > Advanced Tools > 301 Redirect Manager

that map somefile.html to somefile.aspx

Hope it helps,

Joe

6/8/2009 8:51:43 AM
Gravatar
Total Posts 58

Re: 301 for html pages instead of 404

That worked perfectly in dev and stage.  I'll release it to production today.  FCKeditor html file still work too.  Thanks a lot.  I'll owe you a beer.

You must sign in to post in the forums. This thread is closed to new posts.