Fusebox Search Engine Safe URLs
The handling of self, myself,
xfa now allows child tags: parameter can be used to specify URL parameter name / value pairs instead of specifying them directly in the XFA value.
In other words, instead of saying:
you would now say:
<parameter name="id" value="#attributes.id#"/>
</xfa>
This cleanly separates the actual XFA - the fuseaction - from the various URL parameters in the target URL.
Fusebox uses fusebox.xml parameters to construct the URL parameter string. The following (optional) fusebox.xml parameters have been added:
Parameter' | Default | Description |
self | index.cfm | Intended to be the base script name used to generate URLs |
queryStringStart | ? | The string to use between the script name and any URL parameters |
queryStringSeparator | & | The string to use to separate individual URL parameters |
queryStringEqual | = | The string to use between a URL parameter name and its value |
myself | This is constructed as self & queryStringStart & fuseactionVariable & queryStringEqual by default but can be overridden |
This means that you can construct so-called "Search Engine Safe" URLs automatically by specifying different values for these parameters. For example, by setting them all to "/", the XFA shown above becomes:
and the myself value becomes:
Bear in mind that you'll need to use htmlEditFormat() to ensure XHTML compliant HTML is generated.
In addition, you can now specify an XFA name in the
This would construct a redirect to the full URL implied by myself and the XFA:
You can retrieve the framework-generated values for self and myself, as well as updating them on a per-request basis using these new methods on the myFusebox object:
Method | Arguments | Description |
getSelf | Returns the current version of self | |
setSelf | string self | Changes the current version of self and recalculates myself |
getMyself | Returns the current version of myself | |
setMyself | string myself | Changes the current version of myself, allowing non-standard base URLs to be created |
Server Side URL re-Writing
If you want to do the purest form of SES URLs (http://site.com/controller/action) , it requires the removal of the index.cfm which involves having to do some URL rewriting on the web server side. No framework that I know of can avoid URL rewriting if you want to remove the index.cfm
IIS7.5 supports it natively using the web.config or using built-in wizards; Apache has mod_rewrite via .htaccess. There are also 3rd party products for IIS6/7.
While Fusebox 5 does nativly support "SES URL's", the index.cfm file is still within the URL; as follows:
FUSEBOX_PARAMETERS.queryStringSeparator = "/";
FUSEBOX_PARAMETERS.queryStringEqual = "/
Additional Mappings & Railo (servlet-mapping)
For url pattern matching to work in Railo on Tomcat, you can use the web.xml file and add the following:
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
<url-pattern>*.cfml</url-pattern>
<url-pattern>*.cfc</url-pattern>
<url-pattern>*.cfm/*</url-pattern>
<url-pattern>*.cfml/*</url-pattern>
<url-pattern>*.cfc/*</url-pattern>
<url-pattern>/*.cfm/*</url-pattern>
<url-pattern>/cfbuilder/site1/index.cfm/*</url-pattern>
</servlet-mapping>