简体   繁体   English

如何将图像请求重定向到特定文件夹?

[英]How do I redirect image requests to a specific folder?

I currently have a vhost.conf file, setup for a staging server. 我目前有一个vhost.conf文件,用于登台服务器设置。 The problem I'm running into is that I need to have the staging server actually call (only) images from the production server. 我遇到的问题是我需要让登台服务器实际从生产服务器调用(仅)图像。 So, all other file types will call from the staging server, but any image request pulls data from production server. 因此,所有其他文件类型都会从登台服务器调用,但是任何映像请求都会从生产服务器中提取数据。 How would I do this using Apache redirection? 我将如何使用Apache重定向来做到这一点? This is what I currently have in my vhost.conf file 这是我当前在vhost.conf文件中所拥有的

<LocationMatch ".(jpg|gif|png)$">
    SetHandler None
</LocationMatch>

Any ideas? 有任何想法吗?

RewriteEngine On
RewriteRule ^(.+)\.(jpg|gif|png)$ http://production.com$1.$2 [L,R]

Should probably work for you 应该为你工作

Or try this: 或尝试以下方法:

RedirectMatch (.*)\.(gif|jpg|png)$ http://www.anotherserver.com$1.$2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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