Creating DotNetNuke Friendly Urls
Mar
24
Written by:
3/24/2010 6:52 PM
For a long time I have always used the Globals.NavigateUrl() method in DotNetNuke to create links in my custom modules. I have recently converted to using the FriendlyUrl provider in DotNetNuke. The big advantage for me was to create a custom page url for SEO purposes without hacking the DNN framework. I wanted to get rid of the standard Default.aspx and also create urls that were more SEO friendly.
Using the Friendly Url provider is very simple. Simply pass the tab, tab url path, and custom page name.
Example 1:
DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(TabInfo tab, string path, string pageName);
Example 2:
DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(new TabController().GetTab(_tabId), "~/Default.aspx?tabid=" + _tabId "&Parameter1=xyz", "My_Custom_Page_Name.aspx");
This will result in the following url:
http://localhost/Tab_Page_Title/tabid/1/Parameter1/xyz/My_Custom_Page_Name.aspx
This now gives us a nice SEO url!!! If we didnt use the DNN FriendlyUrl provider then our url would look something like this:
http://localhost/tabid/1/Parameter1/xyz/Default.aspx
You can see that there are no useful keywords there for the search engine to pick up!!
Note: In order for this to work, you need to have "HumanFriendly" urls enabled in your web.config file for your dnn installation.
<friendlyUrl defaultProvider="DNNFriendlyUrl">
<providers>
<clear />
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="humanfriendly" />
providers>
friendlyUrl>