Hi Chewi,
I think you should use only one system.webServer directive.
What I usually do in
web.config is
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<!-- rewrite maps --> <rewriteMaps configSource="
webrwmaps.config"></rewriteMaps>
<!-- rewrite rules and redirects--> <rules configSource="
webrwrules.config"></rules>
</rewrite>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="404-notfound.cfm" responseMode="File" />
</httpErrors>
</system.webServer>
</configuration>
so
------------------------------------
<!-- rewrite maps
webrwmaps.config, this is where we rewrite to SEF URLS -->
<rewriteMaps>
<rewriteMap name="
category" defaultValue="" ignoreCase="false">
<add key="/blue-widgets.html" value="/category-listing.cfm?category=100" />
<add key="red-widgets.html" value="/category-listing.cfm?category=100" />
<!-- etc, etc... --> </rewriteMap>
<!-- StaticRedirects --> <rewriteMap name="
StaticRedirects">
<add key="/old-blue-widgets.aspx?id=100" value="/blue-widgets.html" />
<add key="/old-red-widgets.aspx?id=200" value="/red-widgets.html" />
</rewriteMap>
</rewriteMaps>
--------------
Then we have the rules for internal rewrites and URL redirects in
webrwrules.config <rules>
<!-- this one is for rewrites --> <rule name="Rewrite rules for category">
<match url=".*" />
<conditions>
<add input="{
category:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
<!-- this one is for redirects --> <rule name="Redirect Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{
StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="https://
servername.tld{C:1}" appendQueryString="False" redirectType="Permanent" />
</rule>
</rules>
To see the actual REQUEST_URI:
in
application.cfc <cffunction name="
OnRequestEnd" access="public" returntype="void" output="true" hint="Fires after the page processing is complete.">
<cfoutput>
REQUEST_URI: #
CGI.HTTP_X_ORIGINAL_URL#</cfoutput>
<cfreturn />
</cffunction>
------------------------------------------------------
This way you could dynamically/programmatically generate you maps using the programming language of your choice without actually using URL Rewrite 2.0 GUI.
For this to work, you will need to be on IIS7+ with URL Rewrite module installed, there is a lot of info here: [
iis.net...] and here
[
iis.net...]
I have same setup in IIS 7.5/Windows Server 2008 R2 and ColdFusion 10, works like a charm, and feel free to regexp away!
-------------------------------------------
Most CF hosting providers also offer ISAPI rewrite installed, you could also use that, as in .HTACCESS.
I tend to only use .HTACCESS when needed on case by case bases.
Blend27