【问题标题】:Nginx custom uploads rewrite for WordPress Multisite为 WordPress 多站点重写 Nginx 自定义上传
【发布时间】:2017-07-09 15:05:19
【问题描述】:

我在 Nginx 上有一个带有子域的 WordPress 多站点设置。

我想上传这样的网址来工作...

http://mysub.mydomain.com/files/2017/07/myfile.png

文件的位置在哪里...

<web root>/wp-content/uploads/sites/xx/2017/07/myfile.png

这是 Nginx 配置中的位置规则:

location ~ ^/files/(.*)$ {
    try_files /wp-content/uploads/sites/$blogid/$1;
    access_log off; log_not_found off;      expires max;
}

它不起作用,我不明白为什么。

我也尝试过(以及许多变体):

location ^~ /files {
    internal;
    alias /www/wp-content/uploads/sites/$blogid;
    access_log off; log_not_found off;      expires max;
}

如果其中任何一个可以被确认为“应该工作”,那么我将开始查看我的代码中可能优先考虑的更高规则(尽管我还没有跳出来)...

【问题讨论】:

    标签: wordpress nginx multisite


    【解决方案1】:

    这确实有效:

    if (!-e $request_filename) {
        rewrite ^/files/(.*) /wp-content/uploads/sites/$blogid/$1 last;
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 1970-01-01
      相关资源
      最近更新 更多