Customised URLs for CFEclipse
Posted by AJ Mercer at 4:27 pm - Categories: CFML | CFElipse | cfwheels | Railo
Posted by AJ Mercer at 4:27 pm - Categories: CFML | CFElipse | cfwheels | Railo
Railo was so easy to deploy to the 'cloud' using Cloudbees RUN@Cloud. Mark Drew has written up how to deploy Railo to Cloudbees.
I have been messing around with this just to see what 'cloud' computing is all about and just for fun uploaded CFWheels to http://cloudbees.webonix.org (http://cfwheels.webonix.cloudbees.net/ cloudbees lets you add your own domains). But for a wheels site to look sexy it needs friendly URLs.
This is achievable using Tuckey URL Rewrite Filter which I discovered on Aaron Greenlee's website. Extract to the WEB-INF in the root of your website. Edit the WEB-INF/web.xml and add this before the servet tag
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
While you are in this file, also add the following with the rest of the CFML mappings. Tomcat does not allow for multiple wildcards
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>/rewrite.cfm/*</url-pattern>
</servlet-mapping>
Next Create urlrewrite.xml in WEB-INF. This is what I have based on comments in CFWheels doco
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN" "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<!--
Configuration file for UrlRewriteFilter
http://tuckey.org/urlrewrite/
-->
<urlrewrite>
<rule>
<note>
Allow TomCat to have SES links.
</note>
<!--
If our URI ends with one of these extentions we will not perform
a URL rewrite.
-->
<condition type="request-uri" operator="notequal">\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|xml|cfc|ico|php|asp)$</condition>
<!--
If any URI begins with one of these directories, we will not
perform a rewrite. Helpful for running your unit tests or
"blocking" rewrite for some directories.
-->
<condition type="request-uri" operator="notequal">^/$</condition>
<condition type="request-uri" operator="notequal">^$</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>
<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>
<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.cfm(.*)$</condition>
<from>^/(.*)$</from>
<to>/rewrite.cfm/$1</to>
</rule>
</urlrewrite>
Now you can start cloudbees for your site and you should be ready for creating freindly URLS. Which for CFWheels means editing config/settings.cfm and adding
<cfset set(URLRewriting="On")>
And builing links using linkTo(). E.g.
<h1>Page One</h1>
<cfoutput>
#linkTo(text="Page Two", controller="ses", action="pageTwo")#
</cfoutput>
Now you are ready to deploy to the cloud and end up with something like this http://cloudbees.webonix.org/ses/page-one
Posted by AJ Mercer at 4:18 pm - Categories: cfwheels | Railo | cloudbees