Configuring DotNetNuke to Produce a Human Friendly URL

One of the big complaints that I have seen over the years with DotNetNuke has been the horrible URL’s that get produced by the framework.  This is a problem that is part of most dynamically created content on the web, not only DotNetNuke.

For the successful Content Management Systems, they have come up with ways to make these ugly URL’s more human friendly.  DNN did this back in about version 3.0 with the introduction of Friendly URL’s.  This allowed us to get rid of the dreaded querystring for SEO purposes.  So we went from URL’s that looked like http://domain.com/Default.aspx?tabid=39 to http://domain.com/Home/tabid/36/Default.aspx.

This was great for getting better rankings with the pages in the search engines but doesn’t give us that URL that is easy to remember in human terms.  This is the default setup that has made it’s way into the DotNetNuke eco-system, and has given us this common complaint about DotNetNuke sites in general.

There is a solution to this that anyone who is looking to make their site distinctive and remove that stigma about it being a DNN site can use.  It is available within the core framework itself we just need to make some changes to the configuration of the web application.

So lets look at the default configuration in the web.config file for the Friendly URL provider:

   1: <friendlyUrl defaultProvider="DNNFriendlyUrl">
   2:   <providers>
   3:     <clear />
   4:     <add name="DNNFriendlyUrl" 
   5:         type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" 
   6:         includePageName="true" 
   7:         regexMatch="[^a-zA-Z0-9 _-]" />
   8:   </providers>
   9: </friendlyUrl>

As you can see it only has a couple of options defined by default in the config file when you first install DNN which are the following:

  1. includePageName: this is set to true by default and determines if we have the name of the page included in our URL when we are in searchfriendly mode of the provider.
  2. regexMatch: I'm not a regex expert by any means.  But the default match allows the inclusion of all upper and lower characters as well as ll numbers, spaces, underscores and dashes.  If I’m wrong someone let me know in the comments would you.

This is what gives us those ugly URL’s everyone complains about. 

Now when we venture into the Core Framework code for the FriendlyUrl Provider, we have a few more options that aren’t shown in the web.config and can really give us some nicer URL’s to work with on our DNN site.

FriendlyURL Provider Options

  1. includePageName: this was explained above.
  2. regexMatch: this was explained above
  3. fileExtension: by default the file extension on DNN is .aspx. I played around with this option and also looked at the code and although it is defined and being pulled into the provider in the code. I don’t see where this is actually doing anything in provider.
  4. urlFormat: this is the real treasure in the provider we have two URL formats that we can use here the default of searchfriendly or humanfriendly. If we do not include it in the web.config then by default it is searchfriendly but if we add this and change it to humanfriendly then we have much nicer URL’s to work within the framework.

So lets change it in our web.config file to be humanfriendly:

   1: <friendlyUrl defaultProvider="DNNFriendlyUrl">
   2:   <providers>
   3:     <clear />
   4:     <add name="DNNFriendlyUrl" 
   5:         type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" 
   6:         includePageName="false" 
   7:         regexMatch="[^a-zA-Z0-9 _-]" 
   8:         fileExtension=".aspx" 
   9:         urlFormat="humanfriendly" />
  10:   </providers>
  11: </friendlyUrl>

Once we do this and save our web.config file. We can go refresh our site, and now should have URLs that look like the following: http://domain.com/home.aspx or http://domain.com/admin.aspx.  It also makes it easier for allowing direct logins without placing a link on the page for logging in because in this format our login page becomes http://domain.com/login.aspx.

I hope that people find this information useful although what we have in DNN is just a basic URL provider there are other providers out there in the DNN community.  When I have time I will try to add some of them to this post or provider another post with a list of them out there.

Technorati Tags: ,,

Posted on 5/16/2009 4:59:31 PM by omacdon

Permalink | Comments (3) | Post RSSRSS comment feed |

Categories: ASP.NET | DotNetNuke | Programming | Software

Tags: , , ,

DotNetNuke 5.1.0.266 Beta released

DotNetNuke Community Edition Well today has been a great day for anyone who uses and develops with DotNetNuke. The first public release of 5.1 was released to everyone on Codeplex today.  Although it wasn’t without mishap today.

The first version that was uploaded and released version 5.1.0.254 had a couple of show stopper issues that prevented the installation of the framework.  This was quickly noticed and replaced with a good version. 

I recommend anyone who is developing modules and skins for DNN and want to get a good look at the direction that the framework is headed, then you should download this version and see what is coming.  There are some great changes that I will document in some future blog posts as time permits over the next week or so.

I will be posting a blog post about the installation of the new version and hope to have that available shortly.

To find out more:

One thing to remember with this software, it is beta software and should not be used in any production system.  This software should only be used for evaluating the software as to new features that will be available in the release.

Technorati Tags: ,,

Posted on 5/13/2009 5:18:33 AM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Cambrian | ASP.NET | DotNetNuke

Tags: , ,

DotNetNuke Team Meeting Notes from 4/30/09

For anyone who may have missed this. I thought I would post this so that everyone can get an idea of where DotNetNuke is headed over the next little while as well as few other things that the Core Team is batting around for the public to know.

DotNetNuke Team Meeting Notes from 4/30/09

Technorati Tags:

Posted on 5/4/2009 3:15:10 PM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke

Tags:

New Microsoft Web Platform Installer Beta 2

During MIX09, the Web Platform Installer was mentioned in the first keynote on Wednesday, March 18. Some of the new features they mentioned were a new Web Application Gallery to install these on your server or local machine easily.

They also talked about some new extensions for IIS 7 as well.  Well they have many new features in this Beta.  I will go over them and I am testing it to see how it will do with installing some PHP applications as they are the hardest for me to get working properly on my Vista Laptop.

Web Platform Installer Download

Overview

The Microsoft Web Platform Installer 2.0 (Web PI) is a free tool that makes it simple to download, install and keep up-to-date with the latest components of the Microsoft Web Platform, including Internet Information Services (IIS), SQL Server Express, .NET Framework and Visual Web Developer. In addition, install popular open source ASP.NET and PHP web apps with the Web PI.

What’s New

Lots of new goodies to play with and as well as configuring Sql Server 2008, PHP and installing several web applications and configuring them for you.

Well off to play with it and see how it goes.

kick it on DotNetKicks.com

Posted on 3/22/2009 4:40:00 AM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: SQL Server | Windows Server | Software | IIS | ASP.NET | DotNetNuke

Tags: , , , , ,

You Searched For User Control in BlogEngine.NET

I received an interesting comment today about my blog.  It was really appreciative of a feature that is included within the blogging engine. Which is the “You Searched For” user control.  This takes the search query that is sent along from the search engine and matches it to a search within the local site when the referrer comes from a search engine.

What especially made me take notice is that the comment came from a member of the DotNetNuke Blog Module team. With a request to understand how this was achieved within my site.  Well I figured I could have just sent back a quick and dumb answer of it is just part of the blogging engine I use.  Which in my case is BlogEngine.NET.  Or I could do what I am doing now and go into to detail about how the blogging engine accomplishes this, which is what was really being looked for.

With that in mind I will walk through how it is accomplished as I think this would be a great control to be a part of the DotNetNuke core Blog Module as well as a module that could be used to allow people to get more search results when they land on a DNN site.  May have to build that.

There are two parts to this to make it work successfully.  The first part is the addition of the user control to skin theme for my blog site.

  1: <blog:SearchOnSearch ID="SearchOnSearch1" 
  2:     runat="server" MaxResults="5" 
  3:     Headline="You searched for"
  4:     Text="Here are some results for the 
  5:     search term on this website" />

The second part is the code that is behind this user control.  First of we have a few properties that can be configured on the control

Properties:

  1. MaxResults: This is the maximum number of results to return to the page if there are any found.
  2. Headline: This is the headline to display for the control when it returns search items found.
  3. Text: This is the text to be displayed below the headline and above the search results.

Class Implementation:

  1: 
  2:  public class SearchOnSearch : Control
  3:  {
  4:      private static Regex _rxSearchTerm = null;
  5:  
  6:      static SearchOnSearch()
  7:      {
  8:  	// Matches the query string parameter "q" and 
  9:         // its value.  Does not match if "q" is blank.
 10:  	_rxSearchTerm = new Regex("[?&]q=([^&#]+)", 
 11:              RegexOptions.Compiled | 
 12:              RegexOptions.IgnoreCase | 
 13:              RegexOptions.CultureInvariant);
 14:      }
 15:  
 16:      public override void RenderControl(
 17:           HtmlTextWriter writer)
 18:      {
 19:   	string html = Html();
 20:   	if (html != null)
 21:   	    writer.Write(html);
 22:      }
 23: 
 24:     /// <summary>
 25:     /// Checks the referrer to see if it qualifies as a search.
 26:     /// </summary>
 27:     private string Html()
 28:     {
 29:         if (Context.Request.UrlReferrer != null 
 30:             && !Context.Request.UrlReferrer.ToString().Contains(
 31:             Utils.AbsoluteWebRoot.ToString()) && IsSearch)
 32:         {
 33: 	    string referrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLowerInvariant();
 34: 	    string searchTerm = GetSearchTerm(referrer);
 35: 	    List<IPublishable> items = Search.Hits(searchTerm, false);
 36:             if (items.Count == 0)
 37:                 return null;
 38:             return WriteHtml(items, searchTerm);
 39: 	}
 40: 
 41: 	return null;
 42:     }
 43: 
 44:     /// <summary>
 45:     /// Writes the search results as HTML.
 46:     /// </summary>
 47:     private string WriteHtml(List<IPublishable> items, 
 48:         string searchTerm)
 49:     {
 50: 	int results = MaxResults < items.Count ? MaxResults : items.Count;
 51: 	StringBuilder sb = new StringBuilder();
 52: 	sb.Append("<div id=\"searchonsearch\">");
 53: 	sb.AppendFormat("<h3>{0} '{1}'</h3>", Headline, HttpUtility.HtmlEncode(HttpUtility.UrlDecode(searchTerm)));
 54: 	sb.AppendFormat("<p>{0}</p>", Text);
 55: 	sb.Append("<ol>");
 56: 
 57: 	for (int i = 0; i < results; i++)
 58: 	{
 59: 		sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", items[i].RelativeLink, items[i].Title);
 60: 	}
 61: 
 62: 	sb.Append("</ol>");
 63: 	sb.Append("</div>");
 64: 
 65: 	return sb.ToString();
 66:     }
 67: 
 68:     /// <summary>
 69:     /// Retrieves the search term from the specified referrer string.
 70:     /// </summary>
 71:     private string GetSearchTerm(string referrer)
 72:     {
 73: 	string term = string.Empty;
 74: 	Match match = _rxSearchTerm.Match(referrer);
 75: 	if (match.Success)
 76: 	{
 77: 		term = match.Groups[1].Value;
 78: 	}
 79: 
 80: 	return term.Replace("+", " ");
 81:     }
 82: 
 83:     /// <summary>
 84:     /// Checks the referrer to see if it is from a search engine.
 85:     /// </summary>
 86:     private bool IsSearch
 87:     {
 88: 	get
 89: 	{
 90: 		string referrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLowerInvariant();
 91: 		return _rxSearchTerm.IsMatch(referrer);
 93:     }
 94:  }

As we can see from the class it checks to see if there is a query “q” attached to the referring url to see if this comes from a search engine. If it does then we want to search the site and see if we have any posts that we can display to the user.

This is really neat and helpful for users.

kick it on DotNetKicks.com

Posted on 3/22/2009 1:48:26 AM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke | BlogEngine.NET | ASP.NET | Programming

Tags: , , ,

DotNetNuke.com gets a Facelift

After their announcement that they were going to have some significant downtown yesterday.  We have awoke this morning to a new revamped site and much greater prominence for the Professional edition of Dotnetnuke.

Way to go!

NewDNNSite

 

Technorati Tags: ,

Posted on 2/14/2009 6:31:52 PM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke | Software

Tags: ,

2009 Florida Code Camps Viewing Online

For anyone that is not located in the Florida Area or who like me live in the vast wasteland and can’t get to these type of events, Will Strohl has provided online viewing today through his the Orlando DotNetNuke User Group site.

This link below provides a list to the sessions for the day.

The Mighty Blog - The personal web site for Will Strohl - 2009 Florida Code Camps Coming - Back to Back

This link provides access to viewing of the tracks as they are presented.

http://orlando.dotnetnukeug.net/ODUGLive.aspx

Technorati Tags: ,

Posted on 2/7/2009 5:07:32 PM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke | Programming

Tags: ,

DotNetNuke Site Updates & Changes – Dogfooding 4.9.2

Well it appears as if the anticipated update to fix issues with 4.9.1 is slowing making it’s way down the line to us.  It was apparently upgraded at the main DotNetNuke site and is now being tested probably at it’s heaviest for now.  Lets hope no major issues are found and hopefully we will also see that long awaited update for 5.0.0 to 5.0.1 as well.

More information can be found by following the link below from Scott Willhite:

Dogfooding DNN 4.09.02 - DotNetNuke Site Updates & Changes - DotNetNuke

Posted on 2/5/2009 5:12:02 PM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke | Programming | Software

Tags: , ,

New DotNetNuke Host Module – Dashboard Part 1

With the release of the latest versions of DNN, there was the introduction of a new host module, the Dashboard.  This module was designed for the new Professional version of DotNetNuke. It’s main purpose is to give information about the server that the framework is running as well as some important information for anyone trying to provide support to another person.

The base module provides us with the following 6 tabs of information:

  1. Web Server
  2. Database Server
  3. Host
  4. Portals
  5. Modules
  6. Skins

Web Server

Dash01

The web server information that is provided gives us lots of useful information for finding out key important information

  • OS Version: This will tell us what version of the operating system we are running on and what service packs are installed with that OS
  • Web Server Version: Each different IIS version has their own requirements on how things work and knowing the version can make life much easier when supporting someone.
  • .NET Framework Version: The version of the .NET Framework that the web site is running under.
  • ASP.NET Identity: This provides us with the identity of the user that ASP.NET is running under.
  • Host Name: The name of the server that the site is being run on.
  • Physical Path: The actual path to the root of the site on the server.
  • Site Url: This provides us with the URL that is used to access the site with a browser.
  • Relative Path: This is the virtual directory path.
  • Server Time: The current date and time on the server.

This takes care of the first part of the module.  I will get part 2 of the post out tomorrow which will cover the Database Server section of the Dashboard.

Technorati Tags:
Reblog this post [with Zemanta]

Posted on 2/5/2009 7:53:43 AM by omacdon

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: DotNetNuke | Software

Tags: ,

DotNetNuke Skinning 101 - Home

For anyone that is having trouble Peter Schotman of interApps has created a basic skin to help people understand skinning within the latest version of DotNetNuke 5.0. 

It is a basic skin from looking at the zip file.  It has the Manifest file for use with DNN 5.0 and contains two skin files and 4 containers within the setup file.

It does not make use of the new widgets in the skin files, but the files are ascx files and not the html/xml combination files that some people are used. It does give a good base for the Manifest file though.

DotNetNuke Skinning 101 - Home

Technorati Tags: ,

kick it on DotNetKicks.com

Posted on 1/24/2009 5:20:21 AM by admin

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Skinning | DotNetNuke

Tags: ,