5
votes

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.

5
Great question. Strange but true: there's very little DNN interest on StackOverflow, but there is some. What solution did you end up using?Dan Rosenstark

5 Answers

5
votes

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

3
votes

Check this out - details here:

http://www.ifinity.com.au/Blog/Technical_Blog/EntryId/19/Rewriting-the-DotNetNuke-Url-Rewriter-Module/

Also, take a look at the existing FriendlyUrl module that's already included in DNN.

If you want to do this on the stock pages, you'll need to crack open the source for it, or write a module that does this independently.

2
votes

To answer your question directly : yes, you can add some code to the DNN Page Settings page. However, you'll be modifying the core code and thus won't be able to easily upgrade your installation when the next DNN release is made.

A lot of people come to DNN and want to write a new Url Rewriter. The problem is not the rewriting : it's getting the DNN framework to generate the correct urls where you would like them - in the menus, in generated links within modules. To really change the rewriting scheme you need to replace/augment the Url Rewriting function, the friendly url generation function, and provide some sort of redirect capability in order to tie old and new Urls together.

1
votes

Another suggestion is Page Blaster, if you are not wishing write your own code. Works well for the sites l use it on.

0
votes

Several of these are great replies... One of the most important things to know if you are just learning about DNN now (2016 and above) is that the realm of URL Rewriting has changed over time within DNN.

Before, in DNN 4.8 and below you had to use an external module/provider such as: PageBlaster or DNN Masters SEO URL REWriter or iFinity URL REWriter all of those are mentioned in some of the answers above.

However, after DNN 4.9, iFinity URL ReWriter was incorporated into the DNN core and you'll find it available in DNN 5, 6, 7,and 8 in different levels of exposure to the interface. You still need to do some updates in the web.config, but much of it is done directly within the Page Settings now.

Any settings that are not within the main managers, you can do either in the web.config, or in the database, or you can look for a DNN module such as X3 DNN URL Management which taps into the database records of the integrated DNN url rewriter and helps manage settings (it is very similar to the old iFinity interface screens/options) but you don't need it, you can work directly, it's just helpful.