Manage Rewrite Rules Web Part
This page shows the Web Part for managing the rules associated with Rewrite Rules.
The Web Part shown in the figure above, shows the following components:
- A list of actions that the user can access (Refer to procedures below for more information).
- The Edit form. This is shown when the user edits a row in the table or clicks 'New'.
- A table of Rewrite Rules found in the xml file.
Access
This Web Part is accessed by the
CMS Admin Panel.
Prerequisites
The Rewrite.xml file is found from the web.config parameter for the 'Path to Url Rewrite file'. Refer to the
CMS Website Configuration File to edit this field.
The web.config file MUST also have a http handler or http module for url rewriting associated with it.
To export a copy of the Rewrite Rules, click the Export link at the top of the form.
Procedures
Procedures include:
Edit a Rewrite Rule
To edit a Rewrite Rule, click the 'Edit' link beside the rule.
When finished, click the save button. This saves the changes to the Rewrite.xml file.
Create a Rewrite Rule
To create a Rewrite Rule, click the 'New' link at the top of the form.
When finished, click the save button. This saves the changes to the Rewrite.xml file.
Delete a Rewrite Rule
To delete a Rewrite Rule, click the 'Delete' link beside the rule.
The change is immediately saved to the Navigation file.
The Rules
The section defines how the rules are interpreted during a page request.
- Redirect: true/false
- Lower Case: true/false
- Path Type: Normal, Absolute, Authority, PathAndQuery, PrefixMatch
- Look For: address typed by the user
- Send To: address where the page request is sent
Redirect option
If the Redirect option is true and the rule matches the incoming address, then the user is redirected to the new page. Note that the user sees the new address in the browser address.
If the Redirect option is false and the rule matches the incoming address, then the page is written to the browser. Note that the user sees the address that they typed in.
Lower Case option
If the Lower case option is true and the rule matches the incoming address AND the Redirect option is true, then the address is written in lower case.
Path Type options
the section describes the how the path is affected by the selection of Path Type.
All actions are defined for the case where the rule matches the incoming address.
Examples of Path Type
Normal Path Type: /login/default.aspx
Absolute Path Type: http://www.wiebeworks.com/mp/admin.aspx
Authority Path Type: www.wiebeworks.com
Path and Query Path Type: /login/default.aspx?name=Carl
Prefix Match Path Type: http://www.wiebeworks.com/login/default.aspx
Prefix Match No Suffix Path Type: http://www.wiebeworks.com/login/default.aspx
Normal is the typical use for path type. It compares the path following the domain name.
Absolute reviews the complete path of the requested page.
Authority is typically used to prefix the domain name with a 'www.'.
Path and Query compares the path and the query following the domain name.
Prefix Match is used to match all files in a specific folder. Note: Redirect flag must be checked.
Prefix Match No Suffix is used to match all files in a specific folder. Note: Redirect flag must be checked. The suffix is not added to the redirect url.
Impact to the web.config file
Application Configuration parameters
There are two parameters in the app.config file that are impacted.
- UrlRewritePath defines the location of the rewrite file. The typical value is "~/xml/rewrite.xml".
- UrlRewriteIgnoreExtensions defines the extensions that are ignored. This is used when the URL rewrite module is used. The default extensions are: ".ico,.jpeg,.jpg,.gif,.png,.css,.js,.swf,.ashx,.axd".
Triggers for URL rewrite
The URL rewrite component uses either an http module or an http handler. Rewrite checking is triggered when a URL hits either one.
URL Rewrite using http handler¶
If the URL Rewrite component is configured for use in the http handler, then the file type that is checked can be selected. This technique must specify the file type that URL Rewrite applies to.
The following code shows the code that is entered in the web.config file for the website.
<httpHandlers>
<add verb="*" path="*.aspx" type="TrackerRealm.WebBase.UrlRewriteFactory, TrackerRealm.WebBase"/>
</httpHandlers>
URL Rewrite using http module
If the URL Rewrite component is configured for use in the http module, then every request for a file sent to the browser is checked. This is the typical configuration for URL Rewrite.
The following code shows the code that is entered in the web.config file for the website.
<httpModules>
<add name="ModuleRewriter" type="TrackerRealm.WebBase.UrlRewriteModule, TrackerRealm.WebBase"/>
</httpModules>
Edit Properties
Custom Edit properties include:
- Admin Role: a comma-delimited list of Roles allowed to use the Web Part
- Url Rewrite Path: the path to the xml file for Rewrite Rules.
- Common COR Edit Features