iFinity Blogs 

Understanding DotNetNuke Friendly Urls and Url Rewriting for SEO

by Bruce Chapman on Monday, April 20, 2009 11:01 AM

I tend to receive a lot of email, enquires and forum posts about the field of Url Rewriting and Friendly Urls in DotNetNuke.  Generally the questions are related to improving the Urls on a site for the purposes of Search Engine Optimisation.

This post is intended to be a go-to resource for those questions, as the answer generally involves a bit of education on how the whole Url scheme in DNN fits together.  It's important to understand the basics before trying to improve upon them.  The aim is to educate on the issues and constraints at hand.

Defining Terms

I'll use some terms throughout this post, so to clear up confusion, this is what I mean:

Url Rewriting : This is the process whereby the Url for a page is intercepted by the website platform, and modified internally, so that the rest of the processing sees the modified Url, rather than the original Url.  In DotNetNuke, this is typically the process of taking a pagename and converting it to a tabid value, so that the rest of the modules in the installation can identify the current page by TabId.  The person viewing the page does not see the change in Url, so the page appears to be located at the original url location.

Friendly Urls : Urls that have very few or no 'database' id's in them.  As a starting point for DNN, this means having no 'TabId' value in the Url.  Friendly Urls also mean not having a query string for relatively static pages.

Querystring Path : This refers to the part of a DNN Url which forms part of a querystring in a rewritten Url.  Many popular DNN modules use a querystring path, such as the blog module, forums module, and others.  Generally, the Querystring Path contains key/value pairs like EntryId/34/  or /forum/11/post/12.  These are rewritten to look like entryid=34 or forum=11&post=12.

SEO Friendly Urls

For the purposes of this entry, I'm going to be making the assumption that an SEO friendly Url has the following features:

- limited amount of path depth (not too many "/"'s in the url)

- maximum amount of relevant keywords in the Url

- minimum amount of non-keyword 'noise' in the Url (chiefly this refers to removing database Id's and productId, TabId, etc)

- all words spaced with a choice of path separation (for example, using +, _ or - to separate keywords in the Url)

The three-legged stool of DNN Urls : Overview of the DNN Url Scheme

I tend to use this analogy when talking about DNN Urls : the whole scheme sits on a 3-legged stool, with each leg being an important part of the system.

The 3 legged stool of DotNetNuke Url Rewriting

Leg 1 is Friendly Url Generation : the process of programmatically creating Friendly Urls for use wherever a page of dynamic content is generated.   The most important use of generated Friendly Urls in DNN is in the Menu system.  All menu providers dynamically build up the menu using a series of calls to the Friendly Url API in DNN, which returns the destination Urls for the relevant pages.  This process is also used for generating other links, like breadcrumbs, blog posts - anywhere a module generates links automatically.  Importantly, the only place Friendly Url Generation isn't used is when the editor of a website inserts a link manually into some Html text.

The Standard DNN Friendly Url Provider generates links that look like either of these three options:
/tabid/45/default.aspx : 'search friendly' urls

/pagename/tabid/45/default.aspx : 'friendly' urls

/pagename.aspx : 'human friendly' urls.

The three options are chosen by modifying the Friendly Url Provider 'urlFormat' attribute.  All standard DNN installs will use the /pagename/tabid/45/default.aspx scheme.

Leg 2 is Url Rewriting : after Friendly Urls are generated by the system for use in internal site links, they will be clicked on by visitors and come back to the server as requests.  These requests don't map to any specific file on the server : all requests for DNN pages are handled by the /default.aspx page.  As such, the requests need to be rewritten to be handled by the /default.aspx page, and to contain any other information in a querystring.

The Standard DNN Url Rewriter rewrites these urls in either of two ways:

1) using the Friendlyurls.config file regex rules to identify a match and associated rewrite pattern.  This is how the pagename/tabid/45/default.aspx rules get rewritten.  If you look through the rules in the config file, you'll see a pattern matching /tabid/xx and rewriting it to /default.aspx?tabid=xx.

2) using a lookup on the tabs table by using the 'human friendly' name, and rewriting the Url that way.  So 'pagename' is looked up, identified as tabid 45, and the Url is rewritten as default.aspx?tabid=45

Leg 3 is Url Redirection : identifying requests that are in a format not preferred by the Url rewriter, and redirecting them to the preferred Url.   A redirect differs from a rewrite in that the visitor to the site will see the Url change, and their browser will go to the new location.  Often this is too fast for the visitor to detect, but they will see that the Url in the address bar of their browser doesn't match the Url that they clicked on.

Redirects in the standard DNN Url Rewriter are used for the following purposes (amongst others)

Handling child portal requests : a 'child' portal shares the top-level domain name with the 'parent' portal.  When you create a child portal in DNN, you can see a new directory is created on the webserver, with the same name as the child portal.  DNN copies a special 'default.aspx' into this directory, and this 'default.aspx' file simply contains a redirect from domain.com/childportal to domain.com?alias=domain.com/childportal

Identifying the correct portal : because a TabId is unique across an entire DNN installation, it's possible to request domain1.com/tabid/45/default.aspx, where tabid 45 actually belongs to the portal called domain2.com.  In this case, the DNN Url Rewriter will redirect your request from the incorrect combination (domain1.com/tabid/45/default.aspx) to the correct combination (domain2.com/tabid/45/default.aspx).


I use the three-legged stool example to clear up confusion amongst many people as to how they can improve the Urls on their DNN site.   The metaphor fits in my mind, because if all three legs aren't sound and working together, the stool falls over, and what is sitting on top of it falls over as well.  In this case, it's the whole DNN site sitting on the three legged stool.  This metaphor gives us the tools to evaluate different DNN url schemes to see if they are a complete solution.

Achieving Advanced Url Rewriting for SEO

With the basics covered, I'll move onto the more involved area of DNN Url handling - having descriptive Urls that drive content on DNN modules.  I receive a lot of requests that are something like this:

"I've got a forum/product catalog/blog/photo gallery/etc module, and the urls are like this : /pagename/tabid/45/thingId/345/default.aspx : how can I change it so that it says /page-name/my-shiny-product.aspx?"

This is an example of the 'querystring path' detailed earlier on.  There's a combination of two problems to solve in order to achieve the outcome:

- the standard DNN Friendly Url Provider / Url Rewriter, even when in 'humanFriendly' mode, reverts to this more verbose pattern whenever a query string path is added into the Url.

- there's no keywords in the Url, so it's very difficult to make it into a Friendly Url.

- whether it's an existing site being upgraded (and thus needing 301 Redirects to migrate old Urls in search engine indexes) or if it is for a new site, where

There's no clear answer to this question, as it depends on a lot of factors, including whether or not the person has written the code themselves, or can change the code, and the way the module in question is structured.

If you don't have access to the code, the best that you can hope for is removal of the 'tabid/45' and 'default.aspx' portions of the Url.  This at least removes as much noise as possible from the Url.  But, without keywords in the Url, there's a limited amount to what you can do with Friendly Url Generation and Url Rewriting.

Using the Standard DNN Url Rewriter / Friendly Url Provider

The standard DNN url rewriter includes a couple of features that most people don't know about and don't use. 

You can add a rule to the FriendlyUrls.config file to interpret a Url like pagename/tabid/45/thingid-35-the-thing-description.aspx : this is relatively trivial for a confident regex author.   However, this is working on only one leg of the Url Stool : the other two legs remain unchanged.  As such, it is of little or no help unless you're creating friendly urls in custom module code or perhaps with a Html/Url replacement module like the iFinity Inline Link Master or even PageBlaster.

You can prop up the redirections leg with the DotNetNuke request filter, this gives you the ability to perform custom redirections based on regex patterns.  This would at least allow you to

Using a Generic ASP.NET Url Rewriting tool

DotNetNuke runs on top of ASP.NET, and there are a rich set of Url Rewriting tools for ASP.NET : new ones are added all the time to the available set.  Some of these are open source/free tools (UrlRewriter.net, UrlRewriting.net) and there are proprietary tools on the market as well. Most of these tools concentrate on closely replicating the functionality of the Mod_Rewrite tool available on Apache.

So, can you use one of these tools to achieve better Url Rewriting with DNN?

The answer is 'no'.  There are two reasons : One, you'd need to keep an entire listing of all tabid / tabname values consistent in the set of rules for the site.  This is OK for a site that is very static, but as soon as you start adding new pages, you impede the functionality of DNN which automatically recognises new pages as they are added.  Two, it's only working on two of the legs of our three-legged stool.  While you can rewrite and redirect the Urls with one of these tools, you're missing out on the all-important Friendly Url Generation.   

While theoretically you could use a hybrid of a Url-replacement scheme and a custom url rewriter to gain the 'three legs', it would be a cumbersome implementation and a mix of products.

What you need for Advanced Url Rewriting & Friendly Urls

To achieve the desired 'page-name/my-shiny-product.aspx' style Urls, there's really two ways of going about it.

1)  Change the module code so that it uses a unique product name lookup instead of a product ID based lookup.  (or gallery id, or forum id, etc).   In this case, 'my-shiny-product' would be the unique Url name that the database could use to lookup and find an individual record.  Obviously this is more difficult than using automatic database-created numeric Id values.  I never promised it would be easy!  You'll also notice that there is no key/value pair here : just a single name.  That's OK, you can either a null key or null value in the querystring - and just lookup the value based on the position.  As long as you handle the cases where the value is mistyped or incorrect, it will work just fine.

2) Change the module code to output some type of text into the Url, and then use a custom rewriting solution to abstract away the unwanted parts of the Url.   An example of this is the Blog module release 3.5 : it started to include the blog title as part of the Url.  This still leaves the entryid/xx section of the path, but the overall SEO value of the blog post increases enormously with relevant keywords in the Url.  Abstracting away the unwanted parts of the Url falls under some advanced Url parameter handling, which I'll cover in another blog post.  You can see this in action at the Seablick Blog : the simple Urls on that site are a result of a custom Url handling scheme implemented with the Ventrian News Articles module.

As can be seen with the Seablick blog, the Url Master module has extensive features to achieve many of the desired outcomes, but in a lot of cases, the module author may need to modify the module-specific portion of the Url scheme to get the best result.    And that will be the topic for a future post.

Blogs Parent Separator Crafty Code
Bruce Chapman

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

14 comment(s) so far...

Anonymous 4/24/2009

Bruce, One thing to keep in mind is that a unique 3 digit number in a page's URL is often beneficial for search engines. For example having a unique 3 (or more) digit number in a URL is a criteria to be included in the Google News index. So moving from /pagename/tabid/45/thingId/345/default.aspx to /page-name/my-shiny-product.aspx is not always the optimal thing to do!<br>

Bruce Chapman 4/24/2009

@eoghan : that's news to me, but if so, fine : my point really is to set the stage for people to start thinking about the Url in terms of how it fits into the overall strategy of the site, rather than as a technical design feature. If you need a 3 digit number in the url, then it's important to design the url to contain that three digit number, while still giving the user an easy-to-understand url.

Anonymous 4/26/2009

Bruce, here's google News' technical requirements for a URL that explains the need for a 3 digit unique URL: <a href="<br>http://www.google.com/support/news_pub/bin/answer.py?hl=en&answer=68323" rel="nofollow">www.google.com/support/news_pub/bin/answer.py?hl=en&answer=68323</a>

Dave 4/29/2009

I purchased the Infinity friendly url product and I am trying to redirect <br><br>www.mydomain.com/default.aspx <br><br>to <br><br>www.mydomain.com<br><br>How can I do this with your module?

Bruce Chapman 4/29/2009

@dave please see the blog post at <a href=" http://www.ifinity.com.au/Blog/Technical_Blog/EntryId/45/301-Redirecting-from-default-aspx-to-the-site-root-the-final-word" rel="nofollow">www.ifinity.com.au/Blog/Technical_Blog/EntryId/45/301-Redirecting-from-default-aspx-to-the-site-root-the-final-word</a>/

Anonymous 8/5/2009

Hi Bruce, how about special characters like ç ã á, see my case: <br> <a href="<br>http://www3.fundabrinq.org.br/dotnetnuke/Junteseàcausa.aspx<br><br>Is" rel="nofollow">www3.fundabrinq.org.br/dotnetnuke/Junteseàcausa.aspx<br><br>Is</a> there a way to avoid this kind of characters?<br><br>Thanks

Bruce Chapman 8/5/2009

@eduardo : the Url Master module can automatically replace accented characters with their plain ascii equivalent. Or, you can create a whole new url for the page with a different translation of the name.

Anonymous 9/30/2009

Sir,<br>After enabling the 'human friendly' URL option, how big of an impact does it have on the robots.txt file? I want to be sure the terms and log in page are not indexed.<br><br>From this:<br>Disallow: /*login=<br>Disallow: /*/ctl=<br>Disallow: /*/ctl/<br><br>To :<br>Disallow: /Terms.aspx<br>

Bruce Chapman 9/30/2009

@doug what you have listed is fine.

Anonymous 11/24/2011

Hi Bruce,<br /><br />I am using DNN 4.9.5 and iFinity Url Master v2.5.0.1. How can I change my article title as a Url? I am using my own article module and have access to code. The thing of I do not have is, sample codes of how this can be achieve using iFinity Url Master DLLs.<br /><br />Would be glad if you can provide sample code to achieve this.<br /><br />Thank you in advance.<br />Emmet

Bruce Chapman 11/24/2011

@Emmet : There are many other blog posts which you should read. Firstly, there is the new custom module providers functionality:<br /><a href="http://www.ifinity.com.au/2011/10/26/Build_your_own_Custom_DotNetNuke_Module_Provider_and_start_creating_the_Friendly_Urls_you_need_for_your_SEO_strategy" rel="nofollow">www.ifinity.com.au/2011/10/26/Build_your_own_Custom_DotNetNuke_Module_Provider_and_start_creating_the_Friendly_Urls_you_need_for_your_SEO_strategy</a><br /><br />And there is also the series on building Friendly Urls into modules - part 2 is probably the best for what you need:<br /><a href="http://www.ifinity.com.au/Blog/EntryId/103/Building-Friendly-Urls-into-DotNetNuke-Modules-Part-2-ndash-Improving-Module-Urls" rel="nofollow">www.ifinity.com.au/Blog/EntryId/103/Building-Friendly-Urls-into-DotNetNuke-Modules-Part-2-ndash-Improving-Module-Urls</a>

Anonymous 1/10/2012

If you're using IIS 6.0 you'll need ISAPI Rewrite... this will get you where you need to be:<br /><br />RewriteRule ^(.*)/tabid/.*$ $1.aspx<br /><br />...strips out everything after /tabid/ and appends .aspx. <br /><br />Cheers!<br />Justin

Anonymous 10/17/2013

Hi Bruce, really like the new URL Rewrite module. However, one small issue: Got something like this: http://www.mysite.co.nz/subpage1?ReturnURL=http%3A%2f%2fwww.mysite.co.nz%2fsubpage2 This will throw a 404 server error. When I change the url to e.g.: http://www.mysite.co.nz/subpage1?ReturnURL=http%3A%2f%2fwww.mysitetest.co.nz%2fsubpage2 it will work. Would you know why this is happening? It seems that the domain cannot be part of the url twice. Thanks Peter

Bruce Chapman 10/21/2013

Peter if you're referring to the new DNN Advanced Urls, please add that as a Q&A question to http://www.dnnsoftware.com/ - it should get answered for you there.

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