- 废话不多说,直接上重点。
- 首先我们需要有一个Nginx(http://nginx.org/)
下载完成以后,进入Nginx下的cof目录,然后打开nginx.conf(修改之前记得备份)
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /file/ {
root E:/imges;
autoindex on;
}
找到Server可以自己另写,也可以直接再Server中增加,为了精华,我这就直接写location了。
这种访问方式为,访问localhost:80/file,会自己去到E:/imges下面寻找。
不要把Image当作代替Root的路径,可以理解为,在root后面追加的一个文件名/
*假如你E:/imges/file/下面有一个a.jpg,name你的访问路径为:
localhost:80/file/a.jpg***
本文介绍如何通过Nginx配置文件服务器,实现特定目录下文件的访问。具体步骤包括下载Nginx、修改配置文件中的监听端口、服务器名称及文件路径等。
525

被折叠的 条评论
为什么被折叠?



