Apache's trailing slash and proxying to RESTful apps
I have a somewhat odd case with the Web app I just deployed today (no, not Rails, it's Merb!). I have a RESTful Documents controller which needs to receive POST requests on /documents. I also have a documents directory in the public document root. The whole thing is hosted behind Apache with mod_proxy_balancer, and mod_rewrite to let Apache serve static files (all as described on the Mongrel site).
So when I would POST to /documents, Apache in its (normally quite useful) wisdom decided to rewrite it to /documents/ and (worse) to change the request to a GET. This is because of mod_dir, which provides the DirectoryIndex directive and the (less well-known) DirectorySlash directive, which defaults to On. So to fix it, I just set DirectorySlash to Off for the documents directory, and bingo, it works.
Now, if I needed directory indexes on the subdirectories of the public/documents/ directory, I'd have to work around, but this is fine for my current setup.
About this entry
You’re currently reading “Apache's trailing slash and proxying to RESTful apps,” an entry on Kevin's random thoughts
- Published:
- April 9th 02:52 PM
- Updated:
- April 9th 07:59 PM
- Sections:
- tech
0 comments
Jump to comment form | comments rss [?]