My Spring app deployed to prod server (shared tomcat 5.5) would respond to all URL calls with 404 error (except /). After 3 days of hard work, I found that:
The problem is that in the production environment tomcat is being
fronted by an apache httpd which does not forward requests to tomcat
for urls of the form /foobar (without an extension). Apache doesn’t
know how to deal with those URLs and tries to serve them as static
files from the disk.
So, I need to configure apache to send all requests to tomcat. I believe, that would require changes to .htaccess files. I have .htaccess files in the below locations:
/public_html/.htaccess
/public_html/WEB-INF/.htaccess
Please help me with .htaccess content to achieve desired objective.
You should configure your
<Location>directive for the URLs that represent your Tomcat application directly in yourhttpd.confconfiguration file — or a corresponding file that is included in a manner that fits in with your distribution (or local environment) configuration. (Look for theincludelines in your main Apache configuration file if you’re not sure whether or not your distribution or local environment is using some mechanism to break apart a configuration file.)If you place the
<Location>directive for your Tomcat install in an.htaccessfile, that file will be re-loaded and re-parsed on every single request, which can have a performance impact. If you place it in the main configuration, it’ll be read and parsed once, at server startup (and each time you use theapachectlrestartoption to reload the configuration).