简体   繁体   中英

Which rewrite rule am I missing(ISAPI on IIS)?

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?

Try replacing the first two rules by this rule:

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^blog/(.*) http://blog.example.com/$1 [P]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM