Last active
December 23, 2015 08:59
-
-
Save imthepitts/6610996 to your computer and use it in GitHub Desktop.
IIS URL Rewrite test case. web.config placed in web root, info.cfm placed in /asdf directory. Outbound rules disabled in URL Rewrite. Simple example of rewriting via CF in onRequestEnd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent> | |
<cffunction name="onRequestEnd"> | |
<!--- Get the generated output ---> | |
<cfset var output = getPageContext().getCFOutput().getBuffer().toString()> | |
<!--- Apply outbound link rules ---> | |
<cfset output = reReplace(output, '/info\.cfm\?subjectid=([^=&]+)', '/info/\1', 'all')> | |
<!--- Clear the previous output and send the rewritten output in its place ---> | |
<cfcontent reset="true"> | |
<cfoutput>#output#</cfoutput> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello world | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> | |
<a href="/asdf/info.cfm?subjectid=1&nameid=1">asfd</a><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="JWildCardHandler" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\1\jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="None" /> | |
<add name="hbmxmlHandler" path="*.hbmxml" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="cfswfHandler" path="*.cfswf" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="cfrHandler" path="*.cfr" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="cfcHandler" path="*.cfc" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="cfmlHandler" path="*.cfml" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="cfmHandler" path="*.cfm" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="jwsHandler" path="*.jws" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
<add name="jspHandler" path="*.jsp" verb="*" modules="IsapiModule" scriptProcessor="C:\JRun4\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" /> | |
</handlers> | |
<defaultDocument> | |
<files> | |
<add value="index.cfm" /> | |
</files> | |
</defaultDocument> | |
<staticContent> | |
<mimeMap fileExtension=".air" mimeType="application/vnd.adobe.air-application-installer-package zip" /> | |
</staticContent> | |
<!-- Rewrite Rules --> | |
<rewrite> | |
<rules> | |
<rule name="Rewrite Info" enabled="true" stopProcessing="false"> | |
<match url="^(.*)/info/([^/]+)/([^/]+)/?$" /> | |
<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="{R:1}/info.cfm?subjectid={R:2}&nameid={R:3}" appendQueryString="true" /> | |
</rule> | |
</rules> | |
<outboundRules> | |
<rule name="Rewrite Info Page" preCondition="IsHTML" enabled="false" stopProcessing="false"> | |
<match filterByTags="A" pattern="^(.*)/info\.cfm\?subjectid=([^=&]+)&(?:amp;)?nameid=([^=&]+)$" /> | |
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"> | |
</conditions> | |
<action type="Rewrite" value="{R:1}/info/{R:2}/{R:3}" /> | |
</rule> | |
<preConditions> | |
<preCondition name="IsHTML"> | |
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> | |
</preCondition> | |
</preConditions> | |
</outboundRules> | |
</rewrite> | |
<!-- Turn off gzip compression--> | |
<urlCompression doStaticCompression="true" doDynamicCompression="false"/> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment