Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx中的重写规则_Nginx - Fatal编程技术网

Nginx中的重写规则

Nginx中的重写规则,nginx,Nginx,重写规则: location / { rewrite ^/([a-z]+)/$ /index.jsp?a=$1 last; } 我在根目录中创建一个目录/abc/,并在/abc/中放置一个index.html 当我访问http://localhost/abc/,我无法获取/abc/index.html 如何制作http://localhost/abc/可以访问吗?创建一个额外的位置块 location /abc { root /your/root/dir/ab

重写规则:

location / {         
    rewrite ^/([a-z]+)/$ /index.jsp?a=$1 last;
}
我在根目录中创建一个目录
/abc/
,并在
/abc/
中放置一个
index.html

当我访问
http://localhost/abc/
,我无法获取
/abc/index.html


如何制作
http://localhost/abc/
可以访问吗?

创建一个额外的位置块

location /abc {
    root /your/root/dir/abc/;
}

谢谢@mre666,其实还有很多其他的目录,我无法一一定义,没有其他出路?我通常只有一个这样的顶级目录,然后是下面所有其他的静态目录,所以我只需要添加一个额外的位置块。谢谢@mre666,我想确定是否有一个真正的目录,不是目录然后重写,我不确定是否合理听起来有点复杂。您可以执行自定义错误处理程序,将404传递给另一个脚本(回退),请参阅nginx文档: