Rewrite a directory to domain

2019-04-30 13:43发布

问题:

I'm struggling with an .htaccess rewrite, can anyone point me in the right direction please?

I want to be able to rewrite all requests to

www.domain.com/images to images.domain.com (the subdomain is on a different server), keeping any filename and sub-folder requests intact.

So requests to www.domain.com/images/folder1/image1.jpg will get the image from images.domain.com/folder1/image1.jpg

Thanks.

回答1:

Use this rule :

RewriteEngine on
RewriteRule ^images/(.*)$ http://images.domain.com/$1 [L,R=301]