Keeping Querystring items out of the URL path in DNN

Return to previous page

  • 4/7/2015



Keeping Querystring items out of the URL path in DNN

Last updated 2 years ago



(Enter the content of this article below)


URL rewriting in DNN works by shifting as many items from a querystring into the URL Path. Thus, for a page like this, /wiki?page=keeping-querystring-items-ouf-of-url becomes /wiki/page/keeping-querystring-items-out-of-url

This works by manipulating the URL to form a path where possible from the items that would normally be included in a querystring.

When using the Advanced URL functionality of DNN, a URL will occasionally be redirected from an older style or unfriendly URL to the most friendly version possible. The redirected URL is formed by using the same rules that are used to generate a URL in the first place - a combination of the DNN page name, and any extra querystring items that are included in the rewritten URL.

However, in some cases, items that are in the querystring should always stay in the querystring. There could be a couple of different reasons for this - some characters are not allowed in the URL path because of security and reserved characters, in other cases, client-side code expects to find certain values in the querystring.

One particular example of this is Google Analytics Campaign Tracking. This generally uses a combination of querystring Ids like '_utm' and '_gclid'. If these values are transcribed to appear in the URL path, then the client-side code no longer works.

The Advanced URL functionality of DNN has regular expression based filters which can be modified and used to alter incorrect behaviour.

This works by matching a requested URL with a regular expression pattern. Any match within the URL path is then shifted to the querystring of the URL.

Figuring out the correct pattern

Taking an example URL of - assume that the /key1/value1 should be in the querystring
The correct URL would then look like

In this scenario the regular expression pattern needs to match the /key1/value1 pair.

In that case, the regular expression pattern is exactly that : /key1/value1 - a straight match.

Taking a scenario where the example URL needed to be -
then in this case you can use a repeating pattern with regular expressions, and the following pattern would work:
This pattern just matches any pair of key and value where a digit follows 'key' and a digit follows 'value'.

Taking the example of Google Analytics campaign tracking, the following pattern matches the Google Campaign variables:


This uses the same pattern for each of the Google utm variables used in campaign tracking.

For Google Adwords, the gclid can be a problem. The correct value would be :

Combining both Adwords and Analytics would be done as :

Updating the Pattern in Evoq Solutions

  • Go to Host->Advanced URL Management
  • Click on 'Regular Expressions'
  • Find the 'Keep in Querystring Regular Expression'
  • Append a | character to the end of the existing pattern (this means 'OR' in regular expressions)
  • Append your new Regular Expression pattern to the end of the value.

Click on update. You can use the 'Test URL' tab to make sure the URLs are behaving as expected.

Updating the Pattern in DNN Platform

The Advanced URL Management page does not exist in the DNN Platform. It is still possible to update the value, following this procedure:

NOTE: This procedure uses direct SQL Access to modify the database. Please only perform this if you are comfortable manipulating the database directly through SQL Queries. Always take a backup before modifying the database directly. The following example shows how to append the Google Analytics campaign tracking value to the current settings.

  • Open up the Host->SQL page within the DNN installation
  • Execute this query :
    select * from {databaseOwner}{objectQualifier}HostSettings where SettingName = 'AUM_KeepInQueryStringRegex'
  • If there is a record returned, write a new query and execute it, clicking the 'Run as Script' checkbox :
    update {databaseOwner}{objectQualifier}HostSettings set SettingValue = SettingValue + '|(/utm[^/]+/[^/]+)+' where SettingName = 'AUM_KeepInQueryStringregex'
  • If there is no query returned from step 2, write a new query and execute it, clicking the 'Run as Script' checkbox :
    insert into {databaseOwner}{objectQualifier}HostSettings (SettingName, SettingValue) values ('AUM_KeepInQueryStringRegex', '/nomo/\d+|/runningDefault/[^/]+|/popup/(?:true|false)|/(?:page|category|sort|tags)/[^/]+|(/utm[^/]+/[^/]+)+')

  • If the query from 3 or 4 above executed without errors, clear the application cache and try out the change.

NOTE: Strictly speaking, if you are executing an insert statement, you should check the standard SettingName and SettingValue for the regex pattern. The value shown above in step 4 is from the 7.1 codebase - this may change in later versions. The standard regex pattern can be found in the FriendlyUrlSettings.cs, in the constructor method for the 'DoNotIncludeInPathRegex' value. See - FriendlyUrlSettings.cs
No sections defined
Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  

Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out