Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
Regex 如何为nginx静态内容配置之后/中的任何路径添加正则表达式?_Regex_Http_Nginx_Nginx Location - Fatal编程技术网

Regex 如何为nginx静态内容配置之后/中的任何路径添加正则表达式?

Regex 如何为nginx静态内容配置之后/中的任何路径添加正则表达式?,regex,http,nginx,nginx-location,Regex,Http,Nginx,Nginx Location,在我的用例中,我希望基于正则表达式从nginx提供静态内容 I.这是我的位置图 location ^\/static\/(.*)$ { root /usr/share/nginx/html; index /file.html; } 所以当我点击endpoint/static/abcde,但是这个配置试图在/usr/share/nginx/html/static/abcde/index.html 我还尝试使用alias而不是root。但是没有运气 二,。相反,我也尝试了以下配

在我的用例中,我希望基于正则表达式从nginx提供静态内容

I.这是我的位置图

location ^\/static\/(.*)$ {
    root   /usr/share/nginx/html;
    index /file.html;
}
所以当我点击endpoint/static/abcde,但是这个配置试图在
/usr/share/nginx/html/static/abcde/index.html

我还尝试使用
alias
而不是
root
。但是没有运气

二,。相反,我也尝试了以下配置

location /static {
    location ~\/(.*)$ {
    alias   /usr/share/nginx/html;
    index /file.html;
    }
}
在本例中,当我点击端点时,它将被永久移动。但是
/static/abcde/
工作正常。我的意思是,如果没有拖尾
/
,它就是在给出错误。但是我不想要尾随的
/


有人能帮我吗?非常感谢您的帮助。

您想要的url是什么?@AHBagheri-
/static/
带或不带尾部斜杠。我的意思是
/static/
/static/
。示例
/static/123423eere
当用户请求/static/abcde时,您希望发生什么事情?@faisalemon-我希望当用户点击
/usr/share/nginx/html/file.html
作为一个实验尝试:
位置/static{alias/usr/share/nginx/html;index file.html;}
您想要的url是什么?@AHBagheri-
/static/
带或不带尾随斜杠。我的意思是
/static/
/static/
。示例
/static/123423eere
当用户请求/static/abcde时,您希望发生什么事情?@faisalemon-我希望当用户点击
/usr/share/nginx/html/file.html
时,可以提供
/static/abcde
的内容,作为一个实验尝试:
位置/static{alias/usr/share/nginx/html;index file.html;}