I’m trying to setup url rewriting to remove index.cfm from my url.
I’m running an apache server in front of railo tomcat. This are my settings:
Apache virtual host
`<VirtualHost *:80>
DocumentRoot “E:/wamp/www/myapp”
ServerName www.myapp.test
ServerAlias www.myapp.test
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /app !
<Proxy *>
Order deny,allow
Allow from all
ProxyPass / http://
`
www.myapp.test
`
</b>:8888/ ProxyPassReverse / http://<b>
www.myapp.test
`
`
:8888/
RewriteEngine On
If it’s a CFML (*.cfc or *.cfm) request, just proxy it to Tomcat:
RewriteRule ^(.+.cf[cm])(/.*)?$ ajp://%{HTTP_HOST}:8009$1$2 [P]
`
my .htaccess
`
RewriteEngine on
#RepeatLimit 0
#SQL Injection Protection --Read More www.cybercrime.gov
#Please uncomment to use these rules if below words does not conflict with your friendly-urls. You may modify accordingly.
#RewriteRule ^.EXEC(@.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.CAST(.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.DECLARE.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.DECLARE%20.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.NVARCHAR.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.sp_password.$ /includes/templates/404.html [L,F,NC]
#RewriteRule ^.%20xp_.$ /includes/templates/404.html [L,F,NC]
BLOCK unsupported HTTP methods
#RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|OPTIONS|POST|PROPFIND|TRACE)$
#RewriteRule .* - [F]
#You may also want to block proxy attempts, if you see those in your logs:
BLOCK attempts to use our server as a proxy, but allow absolute URIs (change example.com to your domain)
#RewriteCond %{THE_REQUEST} ^(GET|HEAD|POST)./?http:// [NC]
#RewriteCond %{THE_REQUEST} !^(GET|HEAD|POST)./?http://(www.)?example.com/
#RewriteRule .* - [F]
#if this call related to adminstrators or non rewrite folders, you can add more here.
RewriteCond %{REQUEST_URI} ^/(.(CFIDE|cfide|CFFormGateway|jrunscripts|railo-context|mapping-tag|fckeditor)).$
RewriteRule ^(.*)$ - [NC,L]
#dealing with flash / flex communication
RewriteCond %{REQUEST_URI} ^/(.(flashservices|flex2gateway|flex-remoting)).$
RewriteRule ^(.*)$ - [NC,L]
#Images, css, javascript and docs, add your own extensions if needed.
RewriteCond %{REQUEST_URI} .(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|ico)$
RewriteRule ^(.*)$ - [NC,L]
#The ColdBox index.cfm/{path_info} rules.
RewriteRule ^$ index.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]
`
My routes
`
// Allow unique URL or combination of URLs, we recommend both enabled setUniqueURLS(false); // Auto reload configuration, true in dev makes sense to reload the routes on every request //setAutoReload(false); // Sets automatic route extension detection and places the extension in the rc.format variable // setExtensionDetection(true); // The valid extensions this interceptor will detect // setValidExtensions('xml,json,jsont,rss,html,htm'); // If enabled, the interceptor will throw a 406 exception that an invalid format was detected or just ignore it // setThrowOnInvalidExtension(true);// Base URL
if( len(getSetting(‘AppMapping’) ) lte 1){
setBaseURL(“http://#cgi.SERVER_NAME#/”);
}
else{
setBaseURL(“http://#cgi.SERVER_NAME#/#getSetting(‘AppMapping’)#/”);
}
// Your Application Routes
addRoute(pattern="/report", handler=“home”, action=“index”);
//addRoute(pattern="/coldfusion", handler=“seo”, action=“pdfReport”);
addRoute(pattern=":handler/:action?");
`
If I try to reach page without index.cfm like this: http://www.myapp.test/Main I get error from TOMCAT but If I add index.cfm in the url the code works as expected: www.myapp.test/index.cfm/Main/index
So what I should set to make this work without index.cfm in the url?
Many thanks