0

有没有一种方法可以设置 nginx 以提供来自 static.example.com 的静态内容 - 无需修改我的所有 php 文件以反映从何处获取图像?

我希望我可以在 nginx conf 文件中做一些技巧。

4

1 回答 1

0

这可能属于 ServerFault,但我认为您正在寻找这样的东西:

rewrite ^(/assets/)(.*)$ http://static.example.com/$2 permanent;

因此,如果您的 PHP 文件引用文件 /assets/images/background.png,则对该文件的调用将被定向到 static.example.com/images/background.png

希望这可以帮助!

于 2011-03-31T10:23:17.087 回答