views:

330

answers:

1

I have the following rules:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^blog/?$ http://blog.example.com/ [P]
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. 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.

What rule am I missing?

A: 

Try replacing the first two rules by this rule:

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^blog/(.*) http://blog.example.com/$1 [P]
Gumbo
That doesn't seem to do it, unfortunately
Coocoo4Cocoa