Archived blog with a focus on DotNetNuke news, tips and tricks, DNN SEO, and insights and opinions about the DNN community at large.

First time here? You may want to check out the blog archive, subscribe to the RSS feed, sign up for free email updates, or follow me on Twitter. Thanks for visiting!

Hacking Hyphens into DNN URLs 

I’m a big fan of Ventrian’s Friendly Urls Provider, which drops the /tabid/60/ part from DNN’s default URLs so you end up with human friendly URLs such as http://www.mydomain.com/about/contactus.aspx.

One important feature is missing though. The perfect URL as far as SEO is concerned looks like this: http://www.mydomain.com/about/contact-us.aspx. But currently the provider does not insert hyphens between words. While Scott McCulloch is working on a solution to incorporate this functionality into the provider, you can apply the following hack to make it happen today.

Sticking with the above example URL, look for the DNN tabid that corresponds to your Contact Us page. For this discussion let's assume the tabid=60. Now make an entry to the SiteUrls.config file via Host Settings | Advanced Settings | Friendly Url Settings as follows:

Match: .*/about/contact-us.aspx
Replace with: ~/Default.aspx?tabid=60

DNN Friendly Url Setting

Then bring up the Page Settings of your Contact Us page and scroll to the very bottom and expand Advanced Settings | Other Settings. Set the Link Type to URL and enter your hyphenated Contact Us page URL into the Location text box.

DNN Site Settings

After that don't forget to click Update and you are done.

A few words of caution. This "solution" is a hack and will only be manageable on small websites controlled by a DNN savvy administrator. It will also take extra effort on your part when linking to these hyphenated pages. The WYSIWYG editor will NOT pick up the hyphenated URL and you are in danger of creating duplicate content in the eyes of search engines with two different URLs leading to the same page. Oh, and it will only work for DNN 4.xx.

If you want to see the above in action visit crestautomall.com and look at URLs under Inventory and About.




Comments

Drew Drew says:

In DNN 4.5.0. If and when you use this hack, the page you are rewriting mysteriously disappears from the "Link Type" Page ( A Page On Your Site ) dropdown. So if you have other links to that page you are forced to use the external url source. Which the url should be in there anyway. If you remove this hack then the page is not restored to the "Link Type" Page ( A Page On Your Site ) dropdown forever. You will have to re-create the page for it to show up again.

Tom Kraak Tom Kraak says:

Yes, I've noticed that myself. But again, it's a "hack" after all :)-

Déclic Vidéo FX Déclic Vidéo FX says:

Hello,

Running DNN 4.5.0, I was very satisfied of this hack... Until I discover that as soon as I click on "setting" of any module, I have the following error:

ModuleId: 392
ModuleDefId: -1
FriendlyName: Module
ModuleControlSource: Admin/Modules/ModuleSettings.ascx
AssemblyVersion: 04.05.00
PortalID: 0
PortalName: Declic Video FX
UserID: X
UserName: XXXXXXXXX
ActiveTabID: 56
ActiveTabName: Free_HFX
RawURL: /xxxxxxxxxxx
AbsoluteURL: /Default.aspx
AbsoluteURLReferrer:
UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: dd0718c2-8dd6-475d-a414-25efcab24037
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.BindData
StackTrace:
Message: DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.BindData()at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.Page_Load(Object sender, EventArgs e)--- End of inner exception stack trace ---
Source:
Server Name: XXXXXXXXX

Any idea ????

Tom Kraak Tom Kraak says:

I have the same issue with any DNN version. It can't seem to build the URL to the settings page due to our screwing around. Again, it's a hack and things like this are expected.

Solve Solve says:

Is there any easy way to accomplish a short url like www.mydomain.com/username and then convert this so that it picks up page that has a normal dnn-friendly-url www.mydomain.com/Profiles/tabid/60/Default.aspx?name=username
This example is for using Xmod and then filtering on the "name" parameter... Easier when building a community kind of page...

Tom Kraak Tom Kraak says:

Sure, this could be done. You would have to roll your own rewrite provider or take advantage of projects such as urlrewriting.net.

Look for an introduction to urlrewriting.net on this blog soon.

Also, URLs without explicit file extensions such as ".aspx" or ".html" require configuration of IIS.

Harjit Harjit says:

Anybody aware of this issue:

So are you trying to say google won't find any url that is not exposed? This is so wrong, it has been confirmed that google can find any url that you can find, even if their are no links pointing to it. Also how do we stop from users making a mistake and the mistakenly type in wrong category name? http://www.dotnetnuke.com/Anyfoldername/tabid/799/Default.aspx returns a valid 200 header, which is wrong, it should return a valid 404 page. This is a serious issue, which will cause google to find supplemental results. I have some sites, that already are returning supplemental results due to this issue. If this is not fixed, every dotnetnuke site will get penalized.

Thanks,

Harjit

Tom Kraak Tom Kraak says:

Harjit, what section of this discussion are you referring to? Where do I say "google won't find any url that is not exposed?"

Harjit Harjit says:

Sorry I thought, thats what u went in your message. But still the problem I highlighted, is a big issue we need to resolve or all of our sites will end up with supplemental results.

Dan Dan says:

"The WYSIWYG editor will NOT pick up the hyphenated URL and you are in danger of creating duplicate content"
I am JUST now getting to understand what this means. I *had* links all over my site that were inserted using the WYSIWYG editor and it's "link to page on this site" shortcut... As it happens, it was inserting the "unfriendly" url- the one with the querystring. Unbeknownst to me, I filled up my Google juicebox with tons of duplicate content in this manner.
Any ideas on the best strategy for undoing the indexed duplicate content? Submit url-removal requests? Tincture of time?

Anyhow, still learning a TON from your blog.
Thanks!

alex alex says:

I downloaded the source and changed the StripNonWord function in the HtmlUtils.vb file to look like the following.

Public Shared Function StripNonWord(ByVal HTML As String, ByVal RetainSpace As Boolean) As String

'Set up Replacement String
Dim RepString As String
If RetainSpace Then
RepString = " "
Else
RepString = ""
End If

'Replace Tags by replacement String and return mofified string
If HTML Is Nothing Then
Return HTML
Else
' Modification
' Author: Alex Kwiatkowski
' Date: 27/12/2007
' Description: Replace spaces in html with a - instead of nothing, also convert
' html name to lower case
'Return System.Text.RegularExpressions.Regex.Replace(HTML, "\W*", RepString)
Dim Stripped As String

Stripped = System.Text.RegularExpressions.Regex.Replace(HTML, "[^\w\-\s]", "")
Stripped = System.Text.RegularExpressions.Regex.Replace(Stripped, "\s+", "-")

Return Stripped.ToLower
End If
End Function

All u need to do is recompile the DotNetNuke.dll and copy it into the /bin folder of your website. This will make sure that Page Names stay the same but when it creates the tab path the spaces in the tab path are replaced with - and it is converted to lower case.

Tom Kraak Tom Kraak says:

Excellent Alex! Thanks for sharing.

Tom Kraak Tom Kraak says:

Please note that there are 3rd party Url rewrite providers available today that handle this job much better.

Hrvoje Komljenovic Hrvoje Komljenovic says:

You can change the DNN core function StripNonWord (it's in the DotNetNuke.Library project). This functions strips all non-url elements from the page path.
I'm also replacing here some Croatian characters with accents to English characters without accents.
Recompile the library and upload new DotNetNuke.dll into your bin folder.
For more info please visit http://support.considero.net

Comments are closed

Subscribe to our Feeds Follow on Twitter