Don't rewrite UserDir requests

February 25, 2008

I run a site that's a Rails application, but I also want it to double as my personal home on the web -- a place to share files and side projects. Since I use Apache, the easiest way to do that is with the `UserDir` module, which serves content from user home directories under URLs like `/~craig/`. The problem is that my Apache configuration uses `mod_rewrite` to funnel all requests through Rails (after checking for cached files). That catches UserDir requests too, which is not what I want. For my own future reference, here's the one-liner that fixes it: ```apache # Don't rewrite UserDir requests RewriteRule ^/~.*$ - [L] ``` The `-` means "don't rewrite," and the `[L]` flag tells mod_rewrite to stop processing further rules. Any request starting with `/~` gets left alone, and everything else continues through to Rails as normal. All hail the mighty [mod_rewrite cheat sheet](http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/).
Questions or thoughts? Get in touch.