Expected behavior: Requests to example.com should redirect to example.com/.
Problem: Requests in a browser (Firefox) to example.com succeed. Requests in a browser to example.com/ redirect to example.com, which is backwards. With curl, neither request redirects and both serve the same content.
$ curl -D - example.com
HTTP/1.1 200 OK
Date: Sun, 23 Oct 2011 05:54:28 GMT
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 27
Connection: close
Servlet handling request: /index.html
$ curl -D - example.com/
HTTP/1.1 200 OK
Date: Sun, 23 Oct 2011 06:01:24 GMT
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 27
Connection: close
Servlet handling request: /index.html
Direct requests to Tomcat behave as expected.
$ curl -D - localhost:8080/myapp
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://localhost:8080/myapp/
Transfer-Encoding: chunked
Date: Sun, 23 Oct 2011 05:50:20 GMT
<html><body><p>Redirecting to <a href="http://localhost:8080/myapp/">http://localhost:8080/myapp/</a></p></body></html>
I believe the problem is with my reverse proxy configuration. (I'm serving static content by Apache from the /a directory in the webapp.)
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /usr/share/tomcat7/webapps/myapp
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/a/
RewriteRule (.*) ajp://localhost:8009/myapp$1 [P]
<Directory /usr/share/tomcat7/webapps/myapp/a>
Order deny,allow
Allow from all
</Directory>
<Directory /usr/share/tomcat7/webapps/myapp>
Order deny,allow
Deny from all
</Directory>
</VirtualHost>