Skip to content

Instantly share code, notes, and snippets.

@neokoenig
Created September 8, 2015 12:38
Show Gist options
  • Save neokoenig/8e3802cd14387a6ddb82 to your computer and use it in GitHub Desktop.
Save neokoenig/8e3802cd14387a6ddb82 to your computer and use it in GitHub Desktop.
Tuckey URL rewrite rules for cfwheels 1.4.2
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule>
<name>Index.cfm Hack</name>
<note>
We need to alias index.cfm -> rewrite.cfm
</note>
<from>^/index.cfm(.*)$</from>
<to type="passthrough">/rewrite.cfm/$1</to>
</rule>
<rule>
<name>cfWheels 1.4.2 URL Rewrite</name>
<note>
Allow TomCat to have SES links.
</note>
<!-- ignore jpegs/favicons etc -->
<condition type="request-uri" operator="notequal">\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|cfc|ico|php|asp)$</condition>
<condition type="request-uri" operator="notequal">^/favicon.ico(.*)$</condition>
<condition type="request-uri" operator="notequal">^/robots.txt(.*)$</condition>
<condition type="request-uri" operator="notequal">^/sitemap.xml(.*)$</condition>
<condition type="request-uri" operator="notequal">^/rewrite-status(.*)$</condition>
<!-- ignore root rewrite.cfm files, otherwise we get an infinite loop -->
<condition type="request-uri" operator="notequal">^/index.cfm(.*)$</condition>
<condition type="request-uri" operator="notequal">^/rewrite.cfm(.*)$</condition>
<!-- ignore engine specific admins -->
<condition type="request-uri" operator="notequal">^/lucee(.*)$</condition>
<condition type="request-uri" operator="notequal">^/railo-context(.*)$</condition>
<condition type="request-uri" operator="notequal">^/flex2gateway(.*)$</condition>
<condition type="request-uri" operator="notequal">^/jrunscripts(.*)$</condition>
<condition type="request-uri" operator="notequal">^/cfide(.*)$</condition>
<condition type="request-uri" operator="notequal">^/cfformgateway(.*)$</condition>
<!-- ignore cfwheels common directories -->
<condition type="request-uri" operator="notequal">^/files(.*)$</condition>
<condition type="request-uri" operator="notequal">^/images(.*)$</condition>
<condition type="request-uri" operator="notequal">^/javascripts(.*)$</condition>
<condition type="request-uri" operator="notequal">^/miscellaneous(.*)$</condition>
<condition type="request-uri" operator="notequal">^/stylesheets(.*)$</condition>
<!-- misc -->
<condition type="request-uri" operator="notequal">^/fusionreactor(.*)$</condition>
<from>^/(.*)$</from>
<to type="passthrough" last="true">/rewrite.cfm/$1</to>
</rule>
</urlrewrite>
<!-- Example config to add to web.xml -->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<!-- set the amount of seconds the conf file will be checked for reload
can be a valid integer (0 denotes check every time,
-1 denotes no reload check, default -1) -->
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>1</param-value>
</init-param>
<!-- if you need to the conf file path can be changed
it is specified as a path relative to the root of your context
(default /WEB-INF/urlrewrite.xml) -->
<init-param>
<param-name>confPath</param-name>
<param-value>/WEB-INF/urlrewrite.xml</param-value>
</init-param>
<!-- sets up log level (will be logged to context log)
can be: slf4j, TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL,
sysout:{level} (ie, sysout:DEBUG)
if you are having trouble using normal levels use sysout:DEBUG
(default WARN) -->
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
<!-- you can change status path so that it does not
conflict with your installed apps (note, defaults
to /rewrite-status) note, must start with / -->
<init-param>
<param-name>statusPath</param-name>
<param-value>/rewrite-status</param-value>
</init-param>
<!-- you can disable status page if desired
can be: true, false (default true) -->
<init-param>
<param-name>statusEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- you may want to allow more hosts to look at the status page
statusEnabledOnHosts is a comma delimited list of hosts, * can
be used as a wildcard (defaults to "localhost, local, 127.0.0.1") -->
<init-param>
<param-name>statusEnabledOnHosts</param-name>
<param-value>localhost, *.localhost</param-value>
</init-param>
<!-- defaults to false. use mod_rewrite style configuration file (if this is true and confPath
is not specified confPath will be set to /WEB-INF/.htaccess) -->
<init-param>
<param-name>modRewriteConf</param-name>
<param-value>false</param-value>
</init-param>
<!-- load mod_rewrite style configuration from this parameter's value.
note, Setting this parameter will mean that all other conf parameters are ignored.
<init-param>
<param-name>modRewriteConfText</param-name>
<param-value>
RewriteRule ^/~([^/]+)/?(.*) /u/$1/$2 [R]
RewriteRule ^/([uge])/([^/]+)$ /$1/$2/ [R]
</param-value>
</init-param>
-->
<!-- defaults to false. allow conf file to be set by calling /rewrite-status/?conf=/WEB-INF/urlrewrite2.xml
designed to be used for testing only
<init-param>
<param-name>allowConfSwapViaHttp</param-name>
<param-value>false</param-value>
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment