cfheader code 500 instead of 410 gone - coldfusion

I want to show status code 410, but instead it shows status code 500. Can anyone explain why?
I am using IIS7 and ColdFusion 9. This is my code:
<cfheader statuscode="410" statustext="Gone" />
<cfinclude template="../cgi-bin/file_not_found.cfm">
<cfabort>
This is my application.cfc file:
<cfcomponent output="No">
<cfinclude template="f/login.cfm" >
<!--- <cfinclude template="f/security.cfm"> --->
<cfset this.clientmanagement=true>
<cfset this.sessionmanagement="yes">
<cfset this.name="UL">
<cfset this.clientstorage="cookie">
<cfset this.setclientcookies="true">
<cffunction name="OnSessionStart">
<!--- 1111 --->
<!--- set defualt buyer session anyway! --->
<cfset SetDefaultBuyer()>
<cfset SetDefaultSeller()>
<!--- define session and client mylist --->
<cfset session.mylist="">
<!--- <cfif isdefined("client.mylist")><cfset session.mylist=client.mylist><cfelse><cfset session.mylist=""><cfset client.mylist=""></cfif> --->
<!--- trying to login as user --->
<cf_LoginCookies>
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) >
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
</cffunction>
<cffunction name="OnApplicationStart">
<cfinclude template="including/global_variables.cfm">
</cffunction>
<cffunction name="onRequestStart" returnType="boolean">
<!---
<cfif CGI.REMOTE_ADDR IS "81.218.200.52">
<cfelse>
<cfoutput><br> <br> <br>
<h2 align="center">Sorry,<br>
We are in process of maintenance.<br>
Please try at 10:00 AM<br>
Now is #Timeformat(now())#</h2></cfoutput>
<cfabort>
</cfif>
--->
<!--- 2222 --->
<!--- Neged atacks --->
<cfparam name="CGI.QUERY_STRING" default="222">
<cfif FindNoCase('Declare',CGI.QUERY_STRING)>
<cfabort>
</cfif>
<cfif Len(CGI.QUERY_STRING) GT 400>
<cfabort>
</cfif>
<!--- im menase lirot MyUL bli lihiot LogIn --->
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) AND ( NOT ISDefined('form.type') )>
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
<cfreturn True>
</cffunction>
<cfif CGI.HTTP_HOST IS not "192.168.1.223">
<cffunction name="onError">
<cfargument name="Except" required=true/>
<!--- Log all errors in an application-specific log file. --->
<!--- define message --->
<cfif isdefined('except.cause.cause.message')>
<cfset message=except.cause.cause.message>
<cfelseif isdefined('except.cause.message')>
<cfset message=except.cause.message>
<cfelse>
<cfset message=''>
</cfif>
<!--- define template --->
<cfif isdefined('except.cause.tagcontext')>
<cfset template=except.cause.tagcontext[1].template>
<cfset line=except.cause.tagcontext[1].line>
<cfelse>
<Cfset template=''>
<Cfset line=''>
</cfif>
<!--- define second template --->
<cfif arraylen(except.cause.tagcontext) gt 1>
<cfset template= template & ',' & except.cause.tagcontext[2].template>
<cfset line=line & ',' & except.cause.tagcontext[2].line>
<cfelse>
</cfif>
<!--- define third template --->
<cfif arraylen(except.cause.tagcontext) gt 2>
<cfset template= template & ',' & except.cause.tagcontext[3].template>
<cfset line=line & ',' & except.cause.tagcontext[3].line>
<cfelse>
</cfif>
<cfset text="Message: #message# , template:#template# , line:#line#">
<!--- define sql --->
<cfif isdefined('except.cause.sql')>
<cfset text=text & ' , sql:' & except.cause.sql>
</cfif>
<cflog file="MyAppLog" type="error" text="#text# ,client_ip: #cgi.REMOTE_ADDR# , url:#cgi.HTTP_URL#,ref:#cgi.HTTP_REFERER#">
<cfinclude template="/including/error.cfm">
<!--- <cflocation addtoken="false" url="#application.url#/including/error.cfm?message=#message#&template =#template#&line=#line#">
---> </cffunction></cfif>
<cffunction name="onRequest" returnType="boolean">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="f/security.cfm">
<cfinclude template="#Arguments.targetPage#">
<cfreturn True>
</cffunction>
<!---
<cferror type = "request"
template = "../including/error.cfm"
mailto = "dtpozner#gmail.com"> --->
<cffunction name="onRequestEnd" returnType="boolean">
<cfreturn True>
</cffunction>
</cfcomponent>
and this is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="C page detailed">
<match url="^(.*)/(.*)-(.*)/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:4}&cat_id={R:5}&manuf={R:2}& model={R:3}" />
</rule>
<rule name="C page less detailed">
<match url="/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}" />
</rule>
<rule name="C Pages">
<match url="/cc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}" />
</rule>
<rule name="B Page Pnumbers" stopProcessing="true">
<match url="/bb_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="B Pages">
<match url="/bb_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}" />
</rule>
<rule name="TM Guide B Pages">
<match url="/tmm_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/cat_view.cfm?cat_id={R:1}" />
</rule>
<rule name="TMGuide C Page">
<match url="/tmc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/model.cfm?model_id={R:1}" />
</rule>
<rule name="T&M-Buying-Guide" stopProcessing="true">
<match url="^T&M-Buying-Guide" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/index.cfm" />
</rule>
<rule name="Home Page">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/homepage/index.cfm" />
</rule>
<rule name="A Page Pnumbers">
<match url="/aa_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="A Pages">
<match url="/aa_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}" />
</rule>
<rule name="GogglePageModeID">
<match url="/gm_model_id(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="GoogleModelManufCat">
<match url="/gmm_model(.*)_manuf(.*)_cat(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
<rule name="old b_pages" stopProcessing="true">
<match url="^b(\d+?)p(\d+?)pr(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}&old=1" />
</rule>
<rule name="old c_pages" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?)_(.*?)\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& model={R:4}&old=1" />
</rule>
<rule name="old c page no model" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& old=1" />
</rule>
<rule name="old b_tb_pages" stopProcessing="true">
<match url="^b-(.*?)pn(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/cat_view.cfm?cat_id={R:1}&old=1" />
</rule>
<rule name="old c_tb_pages" stopProcessing="true">
<match url="^c-(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/model.cfm?model_id={R:1}&old=1" />
</rule>
<rule name="old b_model_page" stopProcessing="true">
<match url="^b_model_mf(.*?)_mo(.*?)_pn(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="CustomResponse" statusCode="410" statusReason="Removed" statusDescription="Removed" />
</rule>
<rule name="old b_manuf_sec_all" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/b_manuf_sec_all.cfm(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http:www.used-line.com" appendQueryString="false" />
</rule>
<rule name="result.cfm" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/result.cfm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="list_of_categories/categories.cfm" />
</rule>
<rule name="old b model">
<match url="^.*_.*_m(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="old b model mfr cid">
<match url="^.*_.*_2m(.*?)_2mnf(.*?)_2cid(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Like Seybsen said, the 500 status code is returned when there is an error. The error could be happening before you hit the page with the cfheader (so processing is aborted before you can set the status code) or in file_not_found.cfm, wherein the error status code is overriding the statuscode you set.

The primary concern is 500 over here. You can enable "Failed Request Tracking in IIS, as the error 500 is thrown by the webserver. At the same time, analyze the exception/application log for relevant info.

I also would like a more helpful answer on this issue that is still reproducible in CF10 on Windows 2008 R2.
I created a new directory with a blank Application.cfc, with a single Index.cfm page containing the following: Passing in a status code of anything other than 200 returns with a 500 Error code.
<cfparam name="StatusCode" default="200">
<cfparam name="StatusText" default="OK">
<cfif StatusCode EQ "200">
<cfset variables.message = "Success">
<cfelse>
<cfset variables.message = StatusText>
</cfif>
<cfheader statuscode="#StatusCode#" statustext="#StatusText#">
<cfoutput>Message:#variables.message#</cfoutput>
<cfabort>

Related

The domain on IIS is overwriting the Subdirectory

I have an site in IIS, lets say www.example.com (Laravel application) , and i have my subdirectory www.example.com/subdirectory (Django application), when i access the /subdirectory, the domain overwrite my subdirectory and I get 404 page of Laravel,
I tried to make an rule in web.config of domain but i didn't get results, and I don't know what to
So, this is my configs in main.settings( Django)
USE_X_FORWARDED_HOST = True
FORCE_SCRIPT_NAME = '/subdirectory/'
SESSION_COOKIE_PATH = '/subdirectory/'
LOGIN_REDIRECT_URL='/subdirectory/'
LOGOUT_REDIRECT_URL='/subdirectory/'
VIRTUAL_DIRECTORY = "subdirectory/"
ALLOWED_HOSTS = ['example.com', 'localhost', 'wwww.example.com']
and my urlpatterns in main.urls
urlpatterns = [
path(f'{settings.VIRTUAL_DIRECTORY}admin/', admin.site.urls),
# path('password_change/', views.password_change, name='password_change'),
path(f'{settings.VIRTUAL_DIRECTORY}', include('django.contrib.auth.urls')),
path(f'{settings.VIRTUAL_DIRECTORY}', views.index, name='index'),
path(f'{settings.VIRTUAL_DIRECTORY}aluno/', include('aluno.urls')),
path(f'{settings.VIRTUAL_DIRECTORY}empresa/', include('empresa.urls')),
]
and the web.config on Laravel
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/*" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576000" />
</requestFiltering>
</security>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
<add value="Default.htm" />
<add value="default.aspx" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
</files>
</defaultDocument>
<rewrite>
<rules>
<clear />
<!-- INICIO - TO WWW -->
<rule name="Redirect to www" enabled="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>
<!-- FIM - TO WWW -->
<!-- INICIO - HTTP to HTTPS -->
<rule name="HTTP to HTTPS" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
<!-- FIM - HTTP to HTTPS -->
<!-- FIM - LINKS REDIRECIONAMENTOS -->
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" url="/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
<rule name="subdirectory" stopProcessing="true">
<match url="^subdirectory(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
</conditions>
<action type="None" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<handlers>
<remove name="PHP53_via_FastCGI" />
</handlers>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
<caching enabled="true" enableKernelCache="true" />
</system.webServer>
<system.web>
<httpRuntime maxRequestLength="1048576" />
<customErrors mode="Off" />
</system.web>
</configuration>

url rewriting of IIS

with some hit and trail, i managed to remove the extention of the pages which i view for my website, now i want to replace all the ? and = and the & signs with backslash /, I am really Lost now, how do i write that rule in my web config
My Web.Config File:
<rewrite>
<rules>
<rule name="Redirect .cfm extension" stopProcessing="false">
<match url="^(.*).cfm$" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="(.*).cfm$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="hide .cfm extension" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.cfm" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.cfm" />
</rule>
</rules>
</rewrite>
with the above, i managed to get a page like this
http://website.ca/graphics?mode=Graphics%20Design%20%C2%BB%20Business%20cards&catID=35&section=graphics
the graphics? is the one which was before graphics.cfm?

IIS: Regex Including Dot/Period

I have the following rules. The second works but the first doesn't seem to to fire. For example, URL in question for the first rule is index.cfm?section=artists.az&id=22707 and for the 2nd rule which works, the URL is index.cfm?section=artists&id=22707
<rule name="Artists: AZ" stopProcessing="true">
<match url="^index\.cfm$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^section=artists\.az&id=([^=&]+)$" />
</conditions>
<action type="Rewrite" url="artist.php?id={C:1}" appendQueryString="false" />
</rule>
<rule name="Artists: index.cfm" stopProcessing="true">
<match url="^index\.cfm$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^section=artists&id=([^=&]+)$" />
</conditions>
<action type="Rewrite" url="artist.php?id={C:1}" appendQueryString="false" />
</rule>
ANy ideas?

IIS7 URL Redirect with Regex

I'm preparing for a major overhaul of our shopping cart, which is going to completely change how the urls are structured. For what its worth, this is for Magento 1.7.
An example URL would be:
{domain}/item/sub-domain/sub-sub-domain-5-16-7-16-/8083770?plpver=98&categid=1027&prodid=8090&origin=keyword
and redirect it to {domain}/catalogsearch/result/?q=8083710
My web.config is:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Magento Required" stopProcessing="false">
<match url=".*" ignoreCase="false" /> <conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions> <action type="Rewrite" url="index.php" />
</rule>
<rule name="Item Redirect" stopProcessing="true">
<match url="^item/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)(\?.*)" />
<action type="Redirect" url="catalogsearch/result/?q={R:3}" appendQueryString="true" redirectType="Permanent" />
<conditions trackAllCaptures="true">
</conditions>
</rule>
</rules>
</rewrite>
<httpProtocol allowKeepAlive="false" />
<caching enabled="false" />
<urlCompression doDynamicCompression="true" />
</system.webServer>
</configuration>
Right now it seems the redirect is completely ignored, even though in the IIS GUI the sample url passes the regex test. Is there a better way to redirect or is there something wrong with my web.config?
Turns out the answer is here. Can't have a Question Mark in the regex, as IIS treats it as a query string and it needs to be captured in the "conditions" section of the web.config.
So I just took (\?.*) off the end of regex, and added:
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern=".*" />
</conditions>

IIS7 URL Rerwrite - how to replace all underscores with hyphens in a Regex?

I am using the URL Rewrite feature in IIS7 to turn the URL:
/main.asp?category=Name_Of_A_Product
Into:
/category/name-of-a-product/
I have created the redirect & rewrite rules below which do the majority of the work, except I cannot find a way of replacing the underscores with hyphens.
Each URL can have between zero and many underscores and I'm trying to replace them in a single regular expression, to avoid chains of 301 redirects (as I believe that is bad for SEO).
Do you know how (or if) this is can be done?
<rule name="Redirect REAL to FRIEDNLY" enabled="true" stopProcessing="true">
<match url="^main\.asp$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^category=([^=&]+)($|&(.*))$" />
</conditions>
<action type="Redirect" url="category/{ToLower:{C:1}}/" appendQueryString="false" />
</rule>
<rule name="Rewrite FRIEDNLY to REAL" stopProcessing="false">
<match url="^category/([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="main.asp?category={R:1}" />
</rule>
Unfortunately IIS7 has a few limitations:
you can only capture 9 groups C:1 ... C:9
there is only one string function and that's ToLower
Because of that you'll be limited to a URL with a maximum of 9 words separated by max 8 underscores (eg. /main.asp?category=One_Two_Three_Four_Five_Six_Seven_Eight_Nine) and you'll be forced to use 9 rewrite rules:
Single Word: /main.asp?category=Product
<rule name="Redirect REAL to FRIEDNLY 1" enabled="true" stopProcessing="true">
<match url="^main\.asp$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^category=([A-Za-z]+)$" />
</conditions>
<action type="Redirect" url="category/{ToLower:{C:1}}/" appendQueryString="false" />
</rule>
Two Words: /main.asp?category=Some_Product
<rule name="Redirect REAL to FRIEDNLY 2" enabled="true" stopProcessing="true">
<match url="^main\.asp$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^category=([A-Za-z]+)_([A-Za-z]+)$" />
</conditions>
<action type="Redirect" url="category/{ToLower:{C:1}}-{ToLower:{C:2}}/" appendQueryString="false" />
</rule>
Three Words: /main.asp?category=Some_New_Product
<rule name="Redirect REAL to FRIEDNLY 3" enabled="true" stopProcessing="true">
<match url="^main\.asp$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^category=([A-Za-z]+)_([A-Za-z]+)_([A-Za-z]+)$" />
</conditions>
<action type="Redirect" url="category/{ToLower:{C:1}}-{ToLower:{C:2}}-{ToLower:{C:3}}/" appendQueryString="false" />
</rule>
            ...            ...            ...            ...            ...            ...