Nginx配置我为.php抛出了404,如:
## Any other attempt to access PHP files returns a 404.
location ~* ^.+.php${
return 404;
}
但是我在子文件夹中有一些index.php文件,我想运行它.当前配置如下:
location = /sitename/subpage/index.php {
fastcgi_pass phpcgi; #where phpcgi is defined to serve the php files
}
location = /sitename/subpage2/index.php {
fastcgi_pass phpcgi;
}
location = /sitename/subpage3/index.php {
fastcgi_pass phpcgi;
}
它工作得很好,但问题是重复的位置,如果有很多子页面,那么配置变得很大.
我尝试了像*和一些正则表达式的通配符,它说nginx测试通过但是没有加载页面,即404.我尝试的是:
location = /sitename/*/index.php {
fastcgi_pass phpcgi;
}
location ~* ^/sitename/[a-z]/index.php${
fastcgi_pass phpcgi;
}
我有什么方法可以在该位置使用正则表达式或通配符?
最后
以上就是平常音响最近收集整理的关于nginx php的路径匹配,位置路径中的Nginx通配符/正则表达式的全部内容,更多相关nginx内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复