How to setup url rewriting for Wheels with JRUN
Download the binary from Url Rewrite Filter and read the instructions. It is 4 steps. I'll break from the steps after the first one.
Step 1: "extract it into your context's directory ie, so that urlrewrite.xml goes into the WEB-INF directory." I download urlrewritefilter-3.2.0.zip and moved the files to C:\JRun4\servers\cfwheels\cfusion.ear\cfusion.war\WEB-INF\
Open urlrewrite.xml, my file was located at C:\JRun4\servers\cfwheels\cfusion.ear\cfusion.war\WEB-INF\urlrewrite.xml
Search for INSTALLATION, then copy the filter and filter-mapping code from it.
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Next open your web.xml
Mine was located at C:\JRun4\servers\cfwheels\cfusion.ear\cfusion.war\WEB-INF\web.xml
Search for CF Monitoring Filter mappings and paste the copied filter and filter-mapping code above this. You should be below the last </context-param>.
Restart your jrun instance and test. My test url was http://cfunited.local/test/status/ (be sure to have the ending /)
You should be redirected to rewrite-status. This means the url rewriting filter is working. Now to add the CFWheels url rewriting
I used the .htaccess file within the CFWheels download for the rules below. Copy the code below and paste it below the something and above the something in urlrewriting.xml.
The rule is for making CFWheels URLs prettier using URL rewriting.
# http://cfwheels.org/docs/chapter/url-rewriting
# RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|sitemap.xml|rewrite.cfm)($|/.*$) [NC]
# RewriteRule ^(.*)$ ./rewrite.cfm/$1 [L]
^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|sitemap.xml|rewrite.cfm)
^(.*)$
/rewrite.cfm/$1




Posted under: 


You've got a typeo. It should read: condition type="request-uri" vs. condition name="request-uri" ("name" should be "type").
Also, it probably wouldn't hurt to add rewrite rules to prevent access to the various admins (railo-context/admin, CFIDE/Administrator, bluedragon/administrator). I have mine set up so localhost can access those URLs, but nothing else can.
If you're proxying things a certain way, theoretically the external IP could look like localhost, so it's always good to test 'em too. :)
Good stuff man, like the "condensed to one line deal" much better than the other example out there, thanks.
Thanks Denstar. You might be able to figure this out, I haven't dove in too far. It seems with other rewriting setups, I can still go to index.cfm/[controller]/[action] or the even longer index.cfm?controller=[controller]/&action=[action] but with this rewriting currently, I am unable to.
Just retried adding |index.cfm to the end of the condition and now i am able to go to all three urls options. Not sure why it didn't seem to work last Sun :-)
Sweet!
Here's an example of blocking the admins, but it should be tested:
from="^.*/(railo-context/admin/|CFIDE/administrator/|bluedragon/administrator/).*" to="/"
And you can allow localhost with this condition (has the ipv6 addy too, just in case):
condition type="remote-addr" operator="notequal"
127\.0\.0\.1|0:0:0:0:0:0:0:1%0
(I removed the chevrons just in case they get stripped.)