Setting up Sitefinity to forward old Urls to new Urls
• Bryan Napier
My colleague Adam Duggan pointed me to an incredible useful post on the Sitefinity support forums: http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bhamhe.aspx. I mistakenly believed that Sitefinity would support redirecting .ASP files to the new .ASPX counterparts as long as IIS had the .ASP extension associated with the aspnet_isapi.dll runtime. WRONG! As indicated in the forum posting by Randy, the following steps are required:
Step 1: Configure IIS
What happens if you request a non-existent HTM,ASP page?
By default you will get a canned "white page". When you install the .NET Framework is maps certain file extensions to the ASP.NET ISAPI, aspnet_isapi.dll. Neither HTML nor HTM files are mapped to it (because they are not ASP.NET pages). However, you can configure IIS to treat them as ASP.NET pages and serve our custom error pages.
Run the IIS Manager
Select a web application
Right click and go to Properties
On the Virtual Directory tab click Configuration
In the Extension column find .aspx, double click and copy the full path to aspnet_isapi.dll. It should be something like C:WINDOWSMicrosoft.NETFrameworkv2.0.50727aspnet_isapi.dll
Click Add and paste the path in the Executable box
In the Extension box type .html
Make sure Check that file exists is NOT checked
Dismiss all dialogs Step 2: Modify Web.Config
Add as many types as you want into the httphnadler section of your web.config.
voidApplication_Error(objectsender,EventArgse){ExceptionlastException=this.Server.GetLastError();if(lastExceptionisHttpException){HttpExceptionhttpException=(HttpException)lastException;if(httpException.GetHttpCode()==404){// get the name of the requested page - just the /thisPage.htm or /DIR/thisPage.asp etcstringpageName=string.Concat("~",Request.Url.AbsolutePath.ToString());// create a new instance of CmsManagerTelerik.Cms.CmsManagercmsManager=newTelerik.Cms.CmsManager();// let’s get the page by passing one of it’s additional url’sTelerik.Cms.IPagemyPage=cmsManager.GetPageByAdditionalUrl(pageName);// we can cast myPage as ICmsPage and redirect to the Default URLif(myPage!=null){Response.Redirect(((Telerik.Cms.ICmsPage)myPage).DefaultUrl.Url);this.Server.ClearError();}}}}
Now if you come to the site with contact.htm and it doesn’t exist, you will be redirected to contact.aspx.
I hope this helps
A huge thank-you to Randy for not only figuring this out, but posting the results!