我目前有一个主机,我的主要网站托pipe。 我已经在另一台服务器上设置了nginx镜像/caching正在请求的文件,如果它没有,特别是图像和flvvideo。
例如:
www.domain.com是我的主要网站。
www.domain.com/video/video.flv
www.domain.com/images/1.png
我想请问apache将其redirect到imgserv.domain.com(imgserv.domain.com指向另一个服务器IP)
imgserv.domain.com/video/video.flv
imgserv.domain.com/images/1.png
基本上redirect一切与某些文件types和保存的URL的结构,如FLV等
我尝试了一些,但我得到一个redirect循环错误。 有人能帮我吗?
谢谢!
这是我目前所拥有的
RewriteEngine ON RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC] RedirectMatch 302 ^(.*)\.gif$ http://imgserv.domain.com/forums$1.gif RedirectMatch 302 ^(.*)\.jpg$ http://imgserv.domain.com/forums$1.jpg RedirectMatch 302 ^(.*)\.png$ http://imgserv.domain.com/forums$1.png
你正在混合两个不同的模块: RewriteEngine
和RewriteCond
来自mod_rewrite,而RedirectMatch
来自mod_alias 。 他们不能一起工作。
试试这个mod_rewrite的例子:
RewriteEngine ON RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^.*\.(gif|jpg|png)$ http://imgserv.example.com/forums/$0 [L,R]