Rewrite a directory to domain

纵饮孤独 提交于 2019-12-07 06:25:38

问题


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]


来源:https://stackoverflow.com/questions/12194453/rewrite-a-directory-to-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!