Apache Rewrites for Subfolder Install of CFWheels

By default the CFWheels framework and application is installed in the webroot.

But if you want to install it in a subfolder in the webroot, you need to change the rewrites slightly.

I use the following and it works quite well.

In the example below, I have a server called hello.cfwheels.local, and it points to a folder under the webroot called hello.

ServerName hello.cfwheels.local

RewriteEngine On
RewriteOptions Inherit

RewriteCond %{REQUEST_URI} ^.*/(flashservices|flex2gateway|railo-context|robots.txt)($|/.*$) [NC]
RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P,L]

RewriteCond %{REQUEST_URI} ^.*/(files|images|javascripts|miscellaneous|stylesheets|plugins|sitemap.xml|rewrite.cfm)($|/.*$) [NC]
RewriteRule ^(.*)$ http://127.0.0.1:8080/hello$1 [P,L]

RewriteRule ^(.*)$ http://127.0.0.1:8080/hello/rewrite.cfm$1 [P,L]

RewriteRule ^/(.*)$ http://127.0.0.1:8080/hello/rewrite.cfm/$1 [P,L]
ProxyPassReverse / http://127.0.0.1:8080/hello/rewrite.cfm/

ProxyPreserveHost on

If you think there is a better way to accomplish this, please drop in a line.

Comment on this blog post...