
iFinity Friendly Url Provider Module
All Help Topics
How to install the iFinity DNN Friendly Url Provider
This version is for DotNetNuke Installations
of 4.6 and higher, including DNN 5.0 and higheer. Do NOT install this version on earlier version than 4.6
- it is only compatible with 4.6+ versions.
Another, older, version is
available for version 4.0 through 4.5 - however, active support for the 4.5 version has been
stopped.
Note : DNN 5.0 requires a minimum version of 5.0.0 of the Friendly Url Provider.
Step 1: Download the code from the Friendly Url Provider product page.
Step 2: Copy the iFinity.FriendlyUrlProvider.dll in to the /bin directory.
Step 3: Backup your existing web.config
Step 4: Replace this entry:
<add
name="UrlRewrite"
type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules.UrlRewrite"/>
with this entry:
<add
name="UrlRewrite"
type="iFinity.DNN.Modules.FriendlyUrl.UrlRewriteModule, iFinity.FriendlyUrlProvider"/>
Step 5: Add this entry
to the existing "friendlyUrl" provider section:
<add
name="iFinity.FriendlyUrl"
type="iFinity.DNN.Modules.FriendlyUrl.DNNFriendlyUrlProvider, iFinity.FriendlyUrlProvider"
includePageName="true"
regexMatch="[^\+a-zA-Z0-9 _-]"
urlFormat="HumanFriendly"
redirectUnfriendly="true"
doNotRedirect="SearchResults;"
checkForDupUrls="true"
forceLowerCase="false"
redirectWrongCase="false"
replaceSpaceWith="_"
logCacheMessages="false"/>
This set of options will change an 'old' DNN friendly Url like this:
mysite.com/MyTestPage/tabId/65/MyParam/MyValue/default.aspx
to this:
mysite.com/My_Test_Page/MyParam/MyValue.aspx
This set of options is a good starting point for most websites.
Step 6: Change the entry for <friendlyUrl defaultProvider="DNNFriendlyUrl">
to <friendlyUrl defaultProvider="iFinity.FriendlyUrl">
Step 7: Try it out! Note that you may have to restart your application
to get the Friendly Url provider working properly. Also note you must have
your 'Friendly Urls' option in the Host Settings page switched On.
Want More Features?
The Url Master module is the premium offering from ifinity.com.au. Here's what you get:
- all the great features of the iFinity Friendly Url Provider
- Installs through the DNN Module Installer
- Gives you the ability to define any Url for a DNN page
- Allows you to create custom Urls for your DNN pages
- Gives you the tools to create custom redirects for DNN pages, so that you can redirect
from any other Url to a chosen DNN page
- Can generate short, simple urls for the User Profile pages of your site, like http://domain.com/user_name
instaed of domain.com/user-profile/user/3.aspx
- Provides an interactive interface for changing and updating settings
Download a free trial and try it out :
http://www.ifinity.com.au/Products/Url_Master_DNN_SEO_Urls/
Changing Options to use Different Features
The FriendlyUrlProvider is packed
with features to tune the way your website works. This is useful to tailor
the Url behaviour to particular modules or requirements with your website.
You do not need to change anything if your website is working OK, but if you'd like to tweak it, try any of the following changes. Either modify the existing
attribute in the 'FriendlyUrl' config entry, or add the attribute in.
Complete list of web.config options
- urlFormat (HumanFriendly,omitted) -
''humanFriendly'' when using Url values without the standard tabid/nn path. If omitted, will use standard
DNN-style friendly Urls
- doNotRewritePage - regex string for
excluding incoming requests. If the incoming request matches the regex, no
rewriting will be attempted. This is used to handle exceptions, such as direct
calls to pages/controls in the DesktopModules path.
- checkForDupURls (true/false) - true
means an exception will be logged if duplicate urls are found while building the
tab dictionary. Duplicate url''s are urls where the combination of
portalAlias/tabpath from two different portals match. Preference is always given
to the ''first'' portal / tab path combo, so the second and suqsequent combos
will never resolve properly.
- redirectUnfriendly (true/false) -
whether to issue 301 redirect status codes if an incoming url does not match the
friendly url for that page. Also
redirects requests to the site root (mydomain.com/) to the home page of the site
(mydomain.com/home.aspx - assuming 'home.aspx' is the home page name)
- doNotRedirect - semicolon delimited
list of tab paths where a 301 redirect should never be issued. Use when a
particular page should use ?key=val type parameters, or unwanted results are
occuring. This is only used when redirectUnfriendly = true
- doNotRedirectRegex - a regex
expression which, when evaluated against the incoming url, will not redirect if
the result is a match. In the example, the /logoff.aspx page will never 301
redirect. This is only used when redirectUnfriendly = true
- triggerDictionaryRebuildRegex - a regex expression which
will clear out the page index and refresh it on the next request. This allows
tailoring of when the page index gets rebuilt. By default it contains a regex
expression which recognises the DNN 'new page' control so that new pages are included
in the index after being added. If this behaviour is not wanted for performance
reasons, a blank expresssion "" should be included. Apart from that, any valid
regex expression will cause the behaviour. Note that the Regex expression
is applied to the rewritten Url, not the requested Url. (ie default.aspx?tabId=nn,
not /pagename.aspx) This setting can be omitted for the majority of installations.
- parameterHandling (ordered,
firstlast) - ordered means key/value pairs are kept in order, and placed after
the tab path. ie mypage/mykey1/myvalue1/mykey2/myvalue2. firstlast means take
the key of the first parameter and place it last, at the end of the string.
mypage/myvalue1/mykey2/myvalue2/mykey1. Default : firstlast
- pageExtensionUsage (never, pageonly
or always) - three options on whether to use page extensions (ie .aspx) for the
pages. never = don''t use page extensions, pageonly = only use page extensions
when the page path does not include parameter key/value pairs (ie
mysite/mypage.aspx but not mysite/mypage/mykey/myvalue), always = .aspx is
appended to all urls. Default : alwaysUse. If using pageonly or never, the iis
setup must have wildcard mapping to the aspnet_isapi.dll (instructions below)
- ignoreFileTypeRegex (Regex string) -
when mapping wildcard requests to aspnet_isapi.dll, the asp.net url rewriting
function will be called for all types of iis resources on the page. This means
unnecessary file handling for jpeg, gif, css,axd and other file types. By
entering a regex string, any match found will bypass the url rewriting code and
be passed back to iis.
- pageExtension - allows the use of a
page extension other than .aspx if required. (ie .page, .content - whatever)
- forceLowerCase (true, false or omitted) - if set to true, all generated
Url's will be set to lower case.
- forceLowerCaseRegex - this regex pattern (omitted by default) will
prevent the forceLowerCase option from being used for any Urls that match the regex
pattern. This should be used in cases where there is a case-sensitive parameter
in the querystring. Usually this is when a module case a base64 encoded value
which is case sensitive for the decryption.
- redirectWrongCase (true, false or
omitted) - if set to true, all requests sent to the page with the incorrect case
will be 301 redirected to the correct case of the Url.
- replaceSpaceWith
(any valid character, omitted) - if a valid character is supplied, any spaces in
the page name will be replaced with this character for generated Urls. If
omitted, the standard DNN behaviour (spaces removed from page name) is
used. When 'replaceSpaceWith' is used, any requests for
the non-spaces version of that request (ie for mypage instead of my_page) will be
301 redirected, unless there is another page called the same name (ie a
valid mypage exists as well as my page)
- spaceEncodingValue (any valid characters, omitted) - by default,
any spaces in the url path will be encoded with a '+'. However, IIS7 by default
does not allow for '+' in the path. If this is the case, then use %20 as a
space encoding value. Note that this is separate from the replaceSpaceWith
value, which only works on the DNN page names. The space encoding value applies
to other parts of the querystring that get incorporated into the url - generally
this is third party module options where a space is included in the path.
- useBaseFriendlyUrls (list of ; delimited tab paths, with a single
/ for separating path levels) - if a page path is included in this list, it will
not have a 'humanFriendly' url generated for it. This list is an exclusion
list, and any page that is listed will have the 'standard' DNN friendly Url generated.
This option is normally used when a particular module on a page uses proprietary
query string handling, and is inoperable against the Friendly Url Provider.
You can exclude this page and maintain standard operations, while using human friendly
Urls for the rest of the site. Note: to get the page paths, look at the dnn_Tabs.TabPath
table.
-
triggerDictionaryRebuildRegex(Regex String) - when supplied, any Rewritten Url that matches
this regex will result in the Page index for the DNN installation being rebuilt. The Page index is cached between
requests for performance, but any new page or page change that is performed on the site will need the page index to be rebuilt.
It is not required for most installations, and if a new value is added, it should also include the following regex (for page add/edit, portal add/edit)
- the recommended value is triggerDictionaryRebuildRegex="&ctl=tab|/ctl/tab|/Admin/Tabs/"
- allowDebugCode (true, false, or omitted) - allows debug response
headers to be output when a request param or query string param of _fpdebug=true
is added to the request. This is used for debugging in html trace programs
like Microsoft Fiddler.
-
redirectDefaultPath (true, false or omitted) - redirects the /default.aspx
url to the site root. Can only be used when running with no page extensions,
otherwise puts the site root requests into a terminal loop due to IIS.
-
forwardExternalUrls (Redirect301, Redirect302, NoRedirect) - each
value determins what to do when a page is requested in a url, and that page has
an external Url specified. The redirect values forward the visitor to the
external page.
-
deletedTabHandling (301RedirectToHome, Output404) - specifies
what to do when a page which is deleted (but not removed from the recycle bin) is
requested.
-
rebaseClientPath (true, false, omitted (true)) - the value passed
to the context.Rewrite(url, rebaseClientPath) call that the underlying asp.net rewriting
uses.
-
usePortalAlias="0,www.domain.com;1,www.anothername.com" -
a delimited list of portalid/ portal alias pairs. This list specifies which
of the portal aliases a particular portal shoudl use. Any request to an alias
for that portal which isn't the specified one will result in a 301 redirect to the
specified alias. Use to push non-www to www requests, and to migrate domain
names for sites.
-
sslClientRedirect (true, false, omitted (true)) - if true, uses
a javascript redirect to send a visitor to the http version of a https request,
if the site settings say to do so. If false, uses a server-based 301 redirect.
Use true to avoid a browser warning.
-
cachePersistRestart (true, false) - if true, the page index cache
will be preserved throughout an app restart. If false, it will be rebuilt
on app restart.
-
logCacheMessages (true, false, omitted (true)) - if true, a message
will be inserted into the site log every time the page index is rebuilt. Recommended
to use 'false' unless debugging.
-
cacheTime="1000" - any positive integer, specifying the number
of minutes the page index is requested to be cached for. Note that if the
web server has insufficient resources to maintain this cache, the page index will
be flushed earlier.
- doNotRedirectSecureRegex - regex match pattern. When a match
is found, the standard SSL redirect code will be ignored, and the request will be
completed on the http:// scheme. This is often used for allowing search engines
to index a page without having the page forward to https://.
Troubleshooting Problems
The most useful tool you can use for determining errors is Microsoft Fiddler.
This is a free Http traffic monitoring tool, and will show all the web traffic going
from your computer. You can download it at www.fiddlertool.com
Install your Fiddler tool and work out how to monitor traffic from your browser
to your website. Fiddler generally only works with IE, and it won't work if
you try and request http://localhost requests. Instead, set up your website
at http://machinename where machinename is the name of your web server / development
PC. Note that you need to enter the machinename/websitename into the portal
alias tables in your DNN install.
With Fiddler you can detect 404,500,301 and 302 status return codes for different
requests. You do this by switching the tracing on (F12) and then requesting
the page/site with a problem. You will be able to see the results in fiddler,
and by dragging/dropping the request with the error on to the 'Request' tab, you
can re-submit that request without having to reload your entire web page.
Once you have worked out how to trace requests and responses, you can add this value
to the end of a request : ?_fpdebug=true OR you can add a Http request parameter
of _fpdebug:true. If you do this (and provided the 'allowDebug' setting is
omitted or false) you will get a set of debug information in the response headers.
You can see the response headers by clicking in Fiddler on the 'Inspectors' tab,
then on the 'Headers' tab in the lower right 'Response Headers' section.
Here's an example of a debug response header:
X-FriendlyUrlProvider-Debug: http://computername/dnn500/newpage.aspx, http://computername/dnn500/New_Page.aspx,
Default.aspx?TabId=79, Redirect301, 5.0.0.0
This string shows a number of comma-delimited elements. Here's what they mean,
in order:
- X-FriendlyUrlProvider-Debug : response header name
- http://computername/dnn500/newpage.aspx : originally requested Url
- http://computername/dnn500/New_Page.aspx : redirect destination, if supplied (will
be blank if the request didn't result in a redirect)
- Default.aspx?Tabid=79 : rewrite path. This is what the Url is rewritten to,
so that the rest of the DNN framework see this as the Url and can request querystring
parameters.
- Redirect301 : resulting action. This is an internal action value which the
system uses to determine the logic path of the request. Other values are 'Continue'
(means request handled ok, and should continue); Redirect302 : do a 302 redirect
to the redirect path; Output404 : the request did not match a physical file on the
server, and didn't match an expected DNN tab name, so output a 404 error.
- 5.0.0.0 : the current version of the Friendy Url Provider that handled the request
If you cannot figure out the problem, go onto the Friendly Url Provider support
forum at http://www.ifinity.com.au/Products/Support_Forums/. You'll get the
problem solved much quicker if you can supply the fiddler trace or status of a particular
request. Also useful is any events from the DNN Event log, and the copy of
your DNNFriendlyUrl provider web.config entry.
In the response headers, if there is a redirect, you'll also see a value like this:
X-Redirect-Reason: Spaces Replaced Requested
The X-Redirect-Reason header shows the reason a redirect was done. This may
provide further insight into why a redirect occured.
Typical Errors Encountered
Generally, problems with your website generally fall into one of the following categories:
- 404 Errors (page not found). If you're getting a 404 error, first check to
see if you entered the 'UrlRewrite' entry in the HttpModule section. Remember
if you're using IIS7, it will need to be in the <system.webserver> and if
you're using IIS6, in the <system.web> section. If this is OK, then
check to make sure you have the Url correct, and if the problems affect all pages,
or just a single page. 404 errors often occur on things like images and stylesheets,
which show up as broken links and incorrect formatting of the page.
- Unwanted Redirects. Unwanted redirects often show up looking like 404 errors
(things like broken image links in pages, etc). This usually happens when
the provider thinks it has found an 'unfriendly' url, and tries to forward the request
to a more friendly version. Use Fiddler to find the redirected request, then
work out why it is redirecting. Some modules use requests to custom files
with 'tabId' in the string : often the FriendlyUrlProvider intercepts this and tries
to find the correct matching tab. In these cases you need to exclude this
particular path in the 'doNotRedirectRegex' setting.
- Incorrect rewrites. You may see something where you request a particular page,
but it shows the wrong page. This can also show the parent page of a page
instead of the 'child' page. This normally happens because a match is found
on the parent page, but not on the child page. Normally you would correct
this type of problem by working out what the Url for the child page should be, and
figuring out why it's not matching - for example, you have 'replace spaces' enabled
but are requesting the child page with the wrong url.
Relationship between page extension and parameter handling
The following table shows the different Url results that arise from using the various
values of pageExtensionUsage and parameterHandling.
pageExtensionUsage=�never�*
|
pageExtensionUsage=�always�
|
/Enquiries/
|
/Enquiries.aspx
|
pageExtensionUsage=�never�
*
parameterHandling=�ordered�
|
pageExtensionUsage=�always�
parameterHandling=�ordered�
|
/TagList/Tag/Valuers/
|
/TagList/Tag/Valuers.aspx
|
pageExtensionUsage=�never�
*
parameterHandling=�firstparmlast�
|
pageExtensionUsage=�always�
parameterHandling=�firstparmlast�
|
/TagList/Valuers/Tag/
|
/TagList/Valuers/Tag.aspx
|
pageExtensionUsage=�pageonly�
*
|
pageExtensionUsage=�always�
pageExtension=�.page�
**
|
/Enquiries.aspx
|
/Enquiries.page
|
pageExtensionUsage=�pageonly�
parameterHandling=�ordered�
|
pageExtensionUsage=�always�
pageExtension=�.page�
**
parameterHandling=�ordered�
|
/TagList/Tag/Valuers/
|
/TagList/Tag/Valuers.page
|
pageExtensionUsage=�pageonly�
*
parameterHandling=�firstparmlast�
|
pageExtensionUsage=�always�
pageExtension=�.page�
**
parameterHandling=�firstparmlast�
|
/TagList/Valuers/Tag/
|
/TagList/Valuers/Tag.page
|
- * - Requires modification of the IIS settings to remove page extensions, this option
may not be possible on shared hosts. Check with your website host.
- ** - Requires modification of the IIS settings to set a custom page extension, this
option may not be possible on shared hosts. Check with your website host.
Using the FriendlyUrlProvider to give cleaner, no-extension Url's
This Friendly Url provider has the ability to provide even better Url's if you have the ability to change the default Asp.Net ISAPI mappings on your website. Most shared hosting companies will not allow this, but if you are hosting your website yourself, it is very easy to do.
This will transform a url like this:
mysite.com/MyTestPage/tabId/65/MyParam/MyValue/default.aspx
to this:
mysite.com/My_Test_Page/MyParam/MyValue/
There are two things to do to obtain this behaviour: (1) Modify the web.config settings and (2) Change the IIS settings.
(1) Modify the web.config to support extension-less Url's
Change the DNNFriendlyUrl section in your web.config file so that the pageExtension
value looks like this:
pageExtensionUsage=�never�
(2) Check to make sure correct files are excluded from processing.
The 'ignoreFileTypesRegex' value filters out files which shouldn't be processed
by the Url Rewriter. Scan through this list of extensions and make sure common
values like .ico, .jpg, .gif etc are excluded, unless you have a module which performs
some processing (examples are modules that show per-user images on profile pages).
In these cases you may need to construct a conditional regex statement which allows
files of a certain type through the Url Rewriter, and blocks others.
(3)
Changing IIS Settings to map all requests through the aspnet isapi dll
Warning: This may destabilise your website. Always check this on a test version first, and understand what you are doing! Before you start any changes, always know how to 'get back' to how your site was before starting.
These instructions will vary between IIS 5.0, IIS 6.0, IIS 7.0 and the Workstation and Server versions of 2000/XP/2003/Vista/2008
IIS 5.0
- Windows XP
- open property page for website / virtual directory.
- click the ''configuration'' button, select the ''mappings'' tab
- click on the ''add'' button
- Enter the details:
- Executable = [windows.net]\framework\[ver]\aspnet_isapi.dll (normally at c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll)
- For no page extension -> Extension = .*
- For custom page extension -> Extension = .{your value}
- Verbs = GET,POST,HEAD,DEBUG
- Script Engine :checked
- Check that file exists : unchecked
- Click OK, OK, OK to close and apply changes.
IIS 6.0 - Windows 2003 Server
- open property page for website / virtual directory.
- click the 'home directory' tab
- click the 'configuration' button, select the 'mappings' tab
- click 'insert' next to the 'Wildcard application maps' section
- browse to the aspnet_isapi.dll (normally at c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll)
- Ensure that 'check that file exists' is unchecked
- Click OK, OK, OK to close and apply changes
IIS 7.0 - Windows 2008 Server / Vista
- change the web.config entry in <system.webserver><modules> to <modules
runAllManagedModulesForAllRequests="true">
Then thoroughly test all website functions. And you're done!