I am trying to get Apache to rewrite the URL based on certain conditions but it is failing. I have tried searching for the answer but have come up empty handed. We are using Apache as our webserver and proxying the requests to Tomcat for using our Coldfusion/Lucee code.
Basically what is happening is that the rewrite is working fine for when I am accessing an HTML file but when I try to access a CFM or CFC (Coldfusion) file it will ignore the rewrite rule completely. What I want is to have the URL rewritten before passing through the proxy but for some reason I can not get that to work.
Thanks in advance to anyone that can help me solve this.
This is in my httpd.conf
file:
Here is the Virtual Host file:
<VirtualHost *:80>
ServerName dev.xxxxx.com
DirectoryIndex default.cfm index.cfm index.htm index.html
DocumentRoot "Z:/XXXXXXXXX"
<Directory "Z:/XXXXXXXXX">
Require all granted
Allow from all
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
</Directory>
<Proxy *>
Allow from 127.0.0.1
</Proxy>
RewriteEngine On
DirectoryIndex index.cfm
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:7009/$1$2
</VirtualHost>
Snippet towards the bottom of httpd.conf
<IfModule proxy_module>
<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://127.0.0.1:7009/$1$2
ProxyPassMatch ^/(.+\.cfchart)(/.*)?$ ajp://127.0.0.1:7009/$1$2
ProxyPassMatch ^/(.+\.cfml)(/.*)?$ ajp://127.0.0.1:7009/$1$2
ProxyPassReverse / ajp://127.0.0.1:7009/
</IfModule>
This is in .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^(.*) /index.cfm/$1 [L]