In today's Southern Fried DNN User Group meeting, I'm going to go through an overview of that DNN Core version of the iFinity URL Rewriter as well as discuss two DNN Modules which help with redirect handleing and settings, as well as a set of Web.Config edits to help your DNN site handle other types of extensions for 404 processing such as html and jpg files.
A Little History with DNN URLs & Redirects
Older solutions such as DNNMasters SEO URL Provider or iFinity URL Master Module were the best way back in DNN 4, 5, etc. They would help you take urls from the format
to the more SEO-friendly format of
The iFinity URL rewriter was one of the most popular modules on the Snowcovered store and back in 2012 was purchased and incorporated into the DNN Core and is present in all versions of DNN 7.1+.
Now that it's integrated into the core, we are able to easily set an SEO-friendly URL for any page in DNN...
1. DNN Core SEO-Friendly URL Handler
Many of the topics and ideas about the original iFinity URL handler apply to the current integration within DNN Core. In many ways, knowing how it "used to work" in iFinity can help you understand how it works now. To that end, here's an overview on DNN Friendly URLS and the URL Rewriting process from Bruce Chapman
2. The Missing Controls - X3's DnnUrlManagement Module
If you are using the DNN community edition, then you might find yourself looking for the controls! The settings are present within the database and X3 has provided a module that meets the need with the X3 DNN URL Management pair of modules
(codeplex link will die eventually!)
My tips for installing into DNN are to:
- in the web.config, update the URL settings to the ADVANCED version
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="advanced" />
- install the X3 DNN URL Management module
- set up a blank new page under /Host/ called "Host URL Management"
- set up a blank page under /Admin/ called "Portal URL Management"
- install the module onto the Host page... this process installs BOTH the Host and Admin versions.
- go to the Module Settings for the Admin version and Advanced tab to "Move to Another Page" and move it to the /Admin/Portal-URL-Management page
- save settings on /Host/ page, then save settings on /Admin/ page
At that point, the core settings of the DNN instnace will be running pretty well out-of-the-box. You can set certian important items such as setting the Error404 page for the Portal, you can set exceptions and control regex rules for patterns/actions, but most importantly you can go to the third tab to review the specific URLs that have been saved/set for a specific page in the site.
When you change the name of a page, it will sometimes create new records and set them as 301 status for the new page name/url that is set as the primary (with 200 status). You can also use this setting to create other alternates for the page and can set outgoing query strings if necessary.
An additional note is that these records are stored in the TabURLs database table and can be edited manually if you have many alternate page names/redirects that you need to make.
**. The Old HJT Redirect
You would place this module on your Error 404 page and it would primarily do two unreplacable things:
- It allowed you to make records of individual redirects that you wanted to have that were stored in the database. These could be ANY previous URL format and full string that you placed in including other file types such as jpg, html, etc. You also set the final redirect location which could be a page in the site (any page or dynamic url) or external site/domain. Very manual, but useful!
- Living on the 404 page, it recorded new database records for all unhandeled 404s where the page did not have a redirect rule and incrimented the count. This allowed you to periodically check and setup proper redirects for the records that had more than 5 or 10 hits.
3. Config Redirects
Web.Config Rewrite Rules
In situations where you need to perform a number of redirects for page types that are not within DNN, OR for redirects which need to very specifically redirect to a dynamic page with dynamic folder path or query strings, then one way to handle them is to create redirect records within the Web.Config
This tool can help quickly generate the tags and format them for you. It is easy to work with a spreadsheet or list and generate a series of redirects.
Once placed within the Web.Config and the site restarted, then 404-related traffic for these urls will be given a proper 301 status and the redirect completes successfully.
SiteUrls.Config Rewrite Rules
The other way that you can modify or create new redirect rules is by editing the SiteUrls.Config file.
4. Setting ASP.NET to handle other file types
If you need to have the DNN site handle Error 404 processes or redirects for other file types, then you'll need to make an additional setting within the site's web.config. We'll often use this to help enforce redirects for old sites that have been redeveloped in DNN that now have legacy *.htm, *.html, *.php etc pages that have been bookmarked and linked to over time... you can make these settings to help direct those pages over to their new DNN counterpart pages. Additionally, you can use these settings to have DNN use the Error 404 page for missing .jpg, .png, etc.
<!-- 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" name="HtmlHandler-Classic" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" /-->
<!-- integrated pipeline mode handler to make asp.net handle .htm requests -->
<add modules="ManagedPipelineHandler" name="HtmlHandler-Integrated" path="*.html" precondition="integratedMode" requireaccess="Script" type="System.Web.UI.PageHandlerFactory" verb="GET,HEAD,POST,DEBUG">
<!-- make asp.net handle .html requests -->
<add path="*.html" type="System.Web.UI.PageHandlerFactory" verb="*">
Additional Reading & Information
The following list of links and notes is meant as additional information for you to research and try out! It is by no means an exhaustive list, so please add to suggestions and make additions in the comments. The following list are modules which I have used within my client projects as well as ones that I am currently aware of and will reveiw for future projects/needs. So check them out and let me know your results and questions!
Modules for Redirect
DNN Sharp's Redirect Toolkit
Several interesting features within a solid, well-built module. Here are a few of the points that we've used it for... be sure to check out the site for more information.
- redirect to X page based off of domain name (can be global or only from home page)
- redirect to X based on Geo Location IP address
- redirect users based on roles
- redirect based on referrer
- SO many more redirects
I've not used these others, but they're well worth investigating and trying out:
Modules for URL Management
DNN Sharp's URL Adapter
This module can be used as a replacement for the DNN Core URL rewiter and can help give some further rule logic and control if needed as compared to the DNN Core URL handler.