我试图为某些文件types添加行为,但是因为我的内容不在同一个文件夹中,所以我遇到了一个位置匹配导致Nginx在错误的文件夹中查找内容的问题。
接下来,对/wp-content/themes/ryu/fonts/ClearSans-Regular.woff
的请求使得nginx在/opt/wordpress/wp-content/themes/ryu/fonts/ClearSans-Regular.woff
查找文件而如果我注释的location ~* \.(ogg|ogv|svg|svgz|eot
…部分,Nginx在正确的位置寻找内容。
任何线索我怎么能做到这一点?
server { listen *:80; root /opt/wordpress; location ~* \.(eot|ttf|woff)$ { add_header Access-Control-Allow-Origin *; } location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } location /wp-content/ { alias /opt/wp-content/; try_files $uri =404; } location / { alias /opt/public/; expires 1d; index index.html; try_files $uri @wpsupercache; } }
不添加
root /opt/;
在ogg...
location
节做你想要的? 假设您的示例的文件系统path是/opt/wp-content/themes/ryu/fonts/ClearSans-Regular.woff