Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种方法可以设置 nginx 以提供来自 static.example.com 的静态内容 - 无需修改我的所有 php 文件以反映从何处获取图像?
我希望我可以在 nginx conf 文件中做一些技巧。
这可能属于 ServerFault,但我认为您正在寻找这样的东西:
rewrite ^(/assets/)(.*)$ http://static.example.com/$2 permanent;
因此,如果您的 PHP 文件引用文件 /assets/images/background.png,则对该文件的调用将被定向到 static.example.com/images/background.png
希望这可以帮助!