Rewrite Rules
Here are just a few of those rewrite rules for you for major rewrite engines. You can spice them up as needed.

.htaccess

1
RewriteEngine on
2
#if this call related to adminstrators or non rewrite folders, you can add more here.
3
RewriteCond %{REQUEST_URI} ^/(.*(CFIDE|cfide|CFFormGateway|jrunscripts|railo-context|lucee|mapping-tag|fckeditor)).*$
4
RewriteRule ^(.*)$ - [NC,L]
5
6
#Images, css, javascript and docs, add your own extensions if needed.
7
RewriteCond %{REQUEST_URI} \.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
8
RewriteRule ^(.*)$ - [NC,L]
9
10
#The ColdBox index.cfm/{path_info} rules.
11
RewriteRule ^$ index.cfm [QSA,NS]
12
RewriteCond %{REQUEST_FILENAME} !-f
13
RewriteCond %{REQUEST_FILENAME} !-d
14
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]
Copied!
The above htaccess file might not work combined with Apache. Recent versions of Apache don't send the CGI.PATH_INFO variable to your cfml engine when using ProxyPass and ProxyPassMatch. It that's the case you might need a pathInfoProvider function in your router.cfc
The following solution might work better if you are using a recent version of Apache. This should be part of your .htaccess file
1
#The ColdBox index.cfm/{path_info} rules.
2
RewriteEngine On
3
RewriteRule ^$ /index.cfm?redirect_path=/ [QSA,NS]
4
RewriteCond %{REQUEST_FILENAME} !-f
5
RewriteCond %{REQUEST_FILENAME} !-d
6
RewriteRule ^(.*)$ /index.cfm?redirect_path=%{REQUEST_URI} [QSA,L,NS]
Copied!
Now you can create a pathInfo provider function in your router.cfc which brings back your path info to the router:
router.cfc
1
function PathInfoProvider( event ){
2
var p = cgi.path_info;
3
if (len(p)) {
4
return p;
5
} else if (url.keyExists("redirect_path")) {
6
return url.redirect_path;
7
} else {
8
return "";
9
}
10
}
Copied!

nginx

1
################### LOCATION: ROOT #####################
2
location / {
3
# First attempt to serve real files or directory, else it sends it to the @rewrite location for processing
4
try_files $uri $uri/ @rewrite;
5
}
6
7
################### @REWRITE: COLDBOX SES RULES #####################
8
# Rewrite for ColdBox (only needed if you want SES urls with this framework)
9
# If you don't use SES urls you could do something like this
10
# location ~ \.(cfm|cfml|cfc)(.*)$ {
11
location @rewrite {
12
rewrite ^/(.*)? /index.cfm/$request_uri last;
13
rewrite ^ /index.cfm last;
14
}
15
16
################### CFM/CFC LUCEE HANDLER #####################
17
# The above locations will just redirect or try to serve cfml files
18
# We need this to tell NGinx that if we receive the following requests to pass them to Lucee
19
location ~ \.(cfm|cfml|cfc|jsp)(.*)$ {
20
# Include our connector
21
include lucee.conf;
22
}
Copied!

IIS7 web.config

Please note that URL rewriting is handled by an optional module in IIS. More info here: https://www.iis.net/downloads/microsoft/url-rewrite
1
<?xml version="1.0" encoding="UTF-8"?>
2
<configuration>
3
<system.webServer>
4
<rewrite>
5
<rules>
6
<rule name="Application Administration" stopProcessing="true">
7
<match url="^(.*)quot; />
8
<conditions logicalGrouping="MatchAll">
9
<add input="{SCRIPT_NAME}" pattern="^/(.*(CFIDE|cfide|CFFormGateway|jrunscripts|lucee|railo-context|fckeditor)).*quot; ignoreCase="false" />
10
</conditions>
11
<action type="None" />
12
</rule>
13
<rule name="Flash and Flex Communication" stopProcessing="true">
14
<match url="^(.*)quot; ignoreCase="false" />
15
<conditions logicalGrouping="MatchAll">
16
<add input="{SCRIPT_NAME}" pattern="^/(.*(flashservices|flex2gateway|flex-remoting)).*quot; ignoreCase="false" />
17
</conditions>
18
<action type="Rewrite" url="index.cfm/{PATH_INFO}" appendQueryString="true" />
19
</rule>
20
<rule name="Static Files" stopProcessing="true">
21
<match url="^(.*)quot; />
22
<conditions logicalGrouping="MatchAll">
23
<add input="{SCRIPT_NAME}" pattern="\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls)quot; ignoreCase="false" />
24
</conditions>
25
<action type="None" />
26
</rule>
27
<rule name="Insert index.cfm" stopProcessing="true">
28
<match url="^(.*)quot; ignoreCase="false" />
29
<conditions logicalGrouping="MatchAll">
30
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
31
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
32
</conditions>
33
<action type="Rewrite" url="index.cfm/{PATH_INFO}" appendQueryString="true" />
34
</rule>
35
</rules>
36
</rewrite>
37
</system.webServer>
38
</configuration>
Copied!

Tuckey Rewrite

1
<?xml version="1.0" encoding="utf-8"?>
2
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN" "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
3
<urlrewrite>
4
<rule>
5
<note>ContentBox Media URLs</note>
6
<condition type="request-uri" operator="equal">^/__media/.*lt;/condition>
7
<from>^/(.*)lt;/from>
8
<to type="passthrough">/index.cfm/$1</to>
9
</rule>
10
<rule>
11
<note>Generic Front-Controller URLs</note>
12
<condition type="request-uri" operator="notequal">/(index.cfm|robots.txt|osd.xml|flex2gateway|cfide|cfformgateway|railo-context|lucee|admin-context|modules/contentbox-dsncreator|modules/contentbox-installer|modules/contentbox|files|images|js|javascripts|css|styles|config).*</condition>
13
<condition type="request-uri" operator="notequal">\.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf|woff|ttf|otf)lt;/condition>
14
<condition type="request-filename" operator="notdir"/>
15
<condition type="request-filename" operator="notfile"/>
16
<from>^/(.+)lt;/from>
17
<to type="passthrough">/index.cfm/$1</to>
18
</rule>
19
</urlrewrite>
Copied!
Last modified 3mo ago
Copy link
Edit on GitHub