Best DotNetNuke url rewriting approach?

user53885 picture user53885 · Feb 12, 2009 · Viewed 8.2k times · Source

I would like to implement a URL rewrriter for DotNetNuke. Have questions as to whether this is a good or possible approach and any suggestions other developers may have.

Can I add a dynamic or static route for URL rewriter from the 'Pages'-> 'Add Page' section?

Let's say I'm creating a page called 'Events' underneath the 'Activities' menu item.

Can I write some custom code in DotNetNuke that will add a prompt on the add page screen that assumes I will want a static or dynamic route added for - site.com/Activities/Events Or if I name the page 'Event Calendar' then it would suggest 'site.com/Activities/Event-Calendar'?

I would like any feedback or suggestions on how I would accomplish this! Thank you.

Answer

EfficionDave picture EfficionDave · Jun 3, 2009

If you're using DotNetNuke 4.8 or greater, you just need to enable Human Friendly Urls through the Web.Config.

To enable human friendly urls, replace:

<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" />

with:

<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="HumanFriendly" />

UPDATE: For DNN 7.x and greater, this should now be:

<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="advanced" />

Additional Detail: Enable Human Friendly Urls in DotNetNuke