我正在为symfony应用程序使用nginx docker引擎,我在/var/www/html/project/ezplatform/files/(.*)下有一些图片,我需要将它们暴露给公众。
我尝试在我的nginx配置下添加这个重写配置:
rewrite "^/var/www/html/project/ezplatform/files/(.*)" "/app.php" break;
rewrite "^/var/www/html/project/ezplatform/files/(.*)" "/var/www/html/project
/ezplatform/files/$1" break;但当我尝试访问可用的图像时,仍然面临异常404 Not Found。
任何想法都将不胜感激。
发布于 2019-06-21 14:32:43
尝试向nginx conf添加一个location块,在其中为图像目录定义一个句柄,然后nginx使用该句柄从完整路径中检索文件。像这样:
location /other_images/ {
alias /var/www/html/project/ezplatform/files/;
}你可以使用你的‘虚拟’文件夹路径链接到图片:other_images/example.gif
(所以在HTML、<img src = "other_images/example.gif">中,或者使用symfony语法用于图像链接。)
如果这解决了404 Not Found问题,请让我知道。
https://stackoverflow.com/questions/56692044
复制相似问题