简体   繁体   English

如何使用Nginx在根路径下提供文件?

[英]How to serve file under root path using Nginx?

I have a website laike9m.com, which is served by Nginx. 我有一个网站laike9m.com,由Nginx服务。 I want to access a text file AAA.txt with url laike9m.com/AAA.txt . 我想访问一个文本文件AAA.txt与URL laike9m.com/AAA.txt The text file is on my server, let's say it's $HOME/AAA.txt . 文本文件在我的服务器上,假设它是$HOME/AAA.txt Redirection is not allowed. 不允许重定向。 Current Nginx conf file is here . 当前的Nginx conf文件在这里 Thank you. 谢谢。

location ~ ^(.*\.txt)$ {
    alias /home/laike9m/$1;
}

Solved it. 解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM