ETA: Doh! This was some cerebral flatulence on my part. Adding a RewriteCond %{REQUEST_URI} !^/foo/.*
fixed it. However, I am still curious as to why #1 didn't work.
For those that like beating a dead horse, the actual file now looks like this (if there is a a better way, please jump in):
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} foo\.example\.com
RewriteCond %{REQUEST_URI} !^/foo/.*
RewriteRule (.*) /foo/$1 [NC,L]
I thought I understood mod_rewrite. It appears I was wrong.
I would like to rewrite all /somedoc.html to be /foo/somedoc.html. Simple enough (it would seem).
I have tried two approaches that fail - and one that works but is suboptimal.
1.
RewriteRule ^/$ /foo/ [R]
#1 Does absolutely nothing. Perhaps I am misreading the Apache docs, but I would expect it to do what I am looking for based on what I have read.
2.
RewriteRule (.*) /foo/$1 [NC,L]
#2 Results in a 500 Internal Server Error.
3.
RewriteRule ^.?/(.*) /foo/$1 [NC,L]
#3 Demonstrates that rewriting is working as /x/somedoc.html gets rewritten to /foo/somedoc.html. This is mostly pointless other than an exercise to encourage me about my sanity.
I find #2 puzzling. This is on a shared hosting setup (pair.com). Is it possible that the provider is playing games with mod_rewrite further up the chain?
ETA: Or, is #2 causing a loop? Hmmm, I need more coffee.