I have the following rules with mod_rewrite:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^blog/(.*?)$ http://blog.example.com/$1 [P]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)?$ http://www.example.com/$1 [L,R=301]
What I'm trying to achieve, and it works up to 90% of my expectations, is that any hits to http://www.example.com/blog proxies over to http://blog.example.com. They're two physically separate boxes.
The issue I have here is that if I visit http://blog.example.com/some/dir/foo.php it works fine. However, if I go to http://www.example.com/blog/some/dir/foo.php, it does not work properly.
Is there a major flaw in my rules that's preventing me from doing this proxy of all requests from http://www.example.com/blog to http://blog.example.com/ ?
Thanks all!