我只是被nginx弄湿了脚。过去我用过。htaccess文件位于/wp content/uploads中,因此如果我的开发人员或临时服务器没有该文件,它会重定向到生产服务器:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://production.server.com/m/wp-content/uploads/$1 [L,P]
</IfModule>
我在nginx做这件事运气不好。部分原因可能是因为我的站点此时位于子目录(/m/)中。
# Tells nginx which directory the files for this domain are located
root /srv/www/example/htdocs;
index index.php;
# Subdirectory location settings
location /m {
index index.php;
try_files $uri $uri/ /m/index.php?$args;
location /m/wp-content/uploads {
try_files $uri $uri/ @prod_svr;
}
}
location @prod_svr {
proxy_pass http://production.server.com/m/wp-content/uploads$uri;
}
任何想法都会受到极大的赞赏。