HtAccess - 将请求移动到新子域所需的Mod_Rewrite规则

I have a directory structure in my Php mvc app that is currently like this

/site.com
    .htaccess
    index.php
    /models
    /views..
    /controllers..
    /resources..
        /images.. 
            /misc..
                logo.png
            /products..
                product_image1.jpg
        /js..
        /css..

I want to move the resources folder to its own subdomain so the structure would resemble this

/site.com
    .htaccess
    index.php
    /models
    /views..
    /controllers..

/resources.site.com
    /images.. 
        /misc..
            logo.png
        /products..
             product_image1.jpg
        /js..
        /css..    

I need to know the rewrite rule that redirect requests for anything in the resources folder to the new subdomain instead.

I have tried this rule and a few others but it isn't working.

RewriteEngine On

RewriteBase /resources
RewriteCond %{HTTP_HOST} ^resources$ [NC]
RewriteRule ^(.*)$ http://localhost/resources.site.com/$1 [L]

Any help would be much appreciated. Thanks

The rule you have is a little mixed up. If you want to rewrite requests for the resources directory to a new domain, you don't want to make one of the conditions a request for the new domain. Try something like this in the htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^resources\.site\.com$ [NC]
RewriteRule ^resources/(.*)$ http://resources.site.com/$1 [R=301,L]

This will make it so when you request http://site.com/resources/images/misc/logo.png, you will get redirected to http://resources.site.com/images/misc/logo.png