背景:有时候我一些资源(.js .css etc.)等不想访问我本地的,我想重定向到其他 URL

解决:直接修改 nginx 的配置文件 conf,添加下面的代码

#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|mp3|wav)$ {
    access_log /log/nginx/XXXXXXX.assets.access.log;
#root "C:/you project/assets";#这里可以指向你本地 rewrite
^/temp(.*) /temp$1 break; rewrite ^(.*) https://cdn.assets.com/aeeest$1 permanent; }

 

-access_log:访问日志

-root:一般指向本地静态资源路径

-rewrite:重定向到指定路径

相关文章:

  • 2021-07-28
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-12-02
  • 2022-12-23
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2021-10-16
  • 2021-09-01
  • 2022-01-28
  • 2020-07-21
相关资源
相似解决方案