zromet 发表于 2019-10-13 08:12:08

虚拟目录下图片无法访问

网站目录是
server_name www.xm.com
root /home/wwwroot/web
虚拟目录
location /abc/ {
                      alias /home/wwwroot/xm/bcd/;
                }
以下图片选项 在网站目录中可以正常访问,但在虚拟下就不能访问
如 www.xm.com/a.jpg 可以访问
但 www.xm.com/abc/a.jpg就不能访问,404
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
      {
            expires      30d;
      }
但把这个图片选项删除掉 www.xm.com/a.jpg 和 www.xm.com/abc/a.jpg 都可以正常访问了.
这个是什么问题???
包括 location ~ .*\.(js|css)?$
      {
            expires      12h;
      }
也是一样...删除了,虚拟目录下的路径才能正常访问.

整个nginx 网站配置 lnmp 1.4
server
    {
      listen 80;
      #listen [::]:80;
      server_name www.xm.com;
                rewrite ^(.*) https://$server_name$1 permanent;
      index index.html index.htm index.php default.html default.htm default.php;
      root/home/wwwroot/web;

      #error_page   404   /404.html;

      # Deny access to PHP files in specific directory
      #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

      include proxy-pass-php.conf;

                location /abc/ {
              alias /home/wwwroot/xm/bcd/;
                }
      location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)
      {
            expires      30d;
      }

      location ~ .*\.(js|css)?$
      {
            expires      12h;
      }

      location ~ /.well-known {
            allow all;
      }

      location ~ /\.
      {
            deny all;
      }

      access_log off;
    }



补充内容 (2019-10-13 08:14):
www.xm.com/abc/a.html 也能正常访问

licess 发表于 2019-10-13 12:47:20

如果要图片、js之类的缓存只能在虚拟目录的location里面再嵌套上图片和js的location

zromet 发表于 2019-10-13 14:20:32

licess 发表于 2019-10-13 12:47
如果要图片、js之类的缓存只能在虚拟目录的location里面再嵌套上图片和js的location ...

醍醐灌顶,谢谢....
页: [1]
查看完整版本: 虚拟目录下图片无法访问