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
RewriteEngine on
#if this call related to adminstrators or non rewrite folders, you can add more here.
RewriteCond %{REQUEST_URI} ^/(.*(CFIDE|cfide|CFFormGateway|jrunscripts|railo-context|lucee|mapping-tag|fckeditor)).*$
RewriteRule ^(.*)$ - [NC,L]
#Images, css, javascript and docs, add your own extensions if needed.
RewriteCond %{REQUEST_URI} \.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
RewriteRule ^(.*)$ - [NC,L]
#The ColdBox index.cfm/{path_info} rules.
RewriteRule ^$ index.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]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
#The ColdBox index.cfm/{path_info} rules.
RewriteEngine On
RewriteRule ^$ /index.cfm?redirect_path=/ [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.cfm?redirect_path=%{REQUEST_URI} [QSA,L,NS]Now you can create a pathInfo provider function in your router.cfc which brings back your path info to the router:
nginx
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
Tuckey Rewrite
Last updated
Was this helpful?