location /admin/ { root /aaa/dist; index index.html; }
举个栗子哈,比如nginx里有上面这个配置,假设域名是a.com。
那么我访问a.com/admin/index.html的时候nginx会去这个目录加载这个静态html:/aaa/dist/admin/index.html
现在如果我希望用/admin/后面的url去寻找静态文件那应该怎么配置呢?就是我现在希望这个已经匹配上的/admin/部分,在查找静态文件的时候不要再出现在路径里面了,比如还是上面的url,a.com/admin/index.html,我希望nginx能直接拿后面的url去root目录寻找,也就是寻找/aaa/dist/index.html,那请问大家应该怎么配置呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
root 改成alias 试试alias /aaa/dist/;