We are in the process of switching some of our legacy app to Coldbox a few pages at a time. One of the things we are doing now is taking the old files such as /example.cfm
and breaking it up into views and components to match the Coldbox convention.
However as would be expected when we delete the file /example.cfm
we get a 404 error from Tomcat. The reason for this is because of the way our Apache HTTPD and Tomcat is configured. We proxy any requests that contain .cfm, .cfml, .cfc
in the extension from HTTPD to Tomcat, where as if the request doesn’t contain those file extensions it processes the .htaccess
file in the root directory using the default Coldbox configuration.
I am curious if anyone knows how I would configure it so that it only proxies to Tomcat when a file or directory match is found that contains the above mentioned CFML extensions? We don’t really want to keep around all the old files that will just contain a redirect. Our goal would be to make a Coldbox route that does the redirect for us if someone should visit the old link. Thanks in advance for any help.
NOTE: I have looked at several answers on Stackoverflow that do what I am asking but for some reason I keep getting weird redirect errors and bad requests. I have tried many different combinations but still nothing works so I am hoping someone here has done something similar in the past.
My HTTP VirtualHost for development is setup like so:
<VirtualHost *:80>
DocumentRoot "E:/ExampleDir"
ServerName dev.example.com
RequestHeader set https on
DirectoryIndex default.cfm index.cfm index.htm index.html
RewriteEngine on
<IfModule proxy_module>
ProxyPreserveHost On
ProxyRequests Off
ProxyPassMatch ^/ws/(.*)$ ws://192.168.56.101:8888/ws/$1
ProxyPassMatch ^/(.+\.lucee)(/.*)?$ ajp://192.168.56.101:8009/$1$2
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://192.168.56.101:8009/$1$2
ProxyPassMatch ^/(.+\.cfchart)(/.*)?$ ajp://192.168.56.101:8009/$1$2
ProxyPassMatch ^/(.+\.cfml)(/.*)?$ ajp://192.168.56.101:8009/$1$2
</IfModule>
ErrorDocument 404 /errors/404.cfm
</VirtualHost>
Here is the .htaccess
rules inside of the root directory
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.*(CFIDE|cfide|CFFormGateway|jrunscripts|railo-context|lucee|mapping-tag|fckeditor)).*$
RewriteRule ^(.*)$ - [NC,L]
RewriteCond %{REQUEST_URI} \.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
RewriteRule ^(.*)$ - [NC,L]
RewriteRule ^$ default.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm%{REQUEST_URI} [QSA,L,NS]