Call Us 203.687.6053

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

Hacking Hyphens into DNN URLs

Posted by Tom on Wednesday, March 28, 2007 to DotNetNuke, SEO, DNN Tips and Tricks

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.


Permalink Permalink      Comments 13 Comments      RSS feeds RSS feeds      Email updates Email updates

 

Comments

Comment By Drew on Friday, April 13, 2007 at 4:11 PM

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.

Comment By Tom Kraak on Friday, April 13, 2007 at 4:14 PM

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

Comment By Déclic Vidéo FX on Wednesday, April 18, 2007 at 3:13 PM

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 ????

Comment By Tom Kraak on Wednesday, April 18, 2007 at 3:48 PM

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.

Comment By Solve on Thursday, April 19, 2007 at 12:14 PM

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...

Comment By Tom Kraak on Thursday, April 19, 2007 at 12:38 PM

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.

Comment By Harjit on Thursday, April 19, 2007 at 4:16 PM

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

Comment By Tom Kraak on Thursday, April 19, 2007 at 4:49 PM

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

Comment By Harjit on Thursday, April 26, 2007 at 4:38 PM

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.

Comment By Dan on Saturday, August 25, 2007 at 10:28 AM

"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!

Comment By alex on Thursday, December 27, 2007 at 9:23 AM

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.

Comment By Tom Kraak on Thursday, December 27, 2007 at 3:32 PM

Excellent Alex! Thanks for sharing.

Comment By çiçekçi on Thursday, October 16, 2008 at 5:18 AM

you are very very thankss / paylaşım için çok teşekkürler çalışmalarınızda başarılar diliyorum

Add a comment