【问题标题】:Nginx: Multiple PHP sites in sub-directoriesNginx:子目录中的多个 PHP 站点
【发布时间】:2014-09-09 08:02:39
【问题描述】:

我已经拉头发好几个小时了。

我的 [statamic CMS] 网站在登台服务器的子目录中运行。

  • domain.com/site1/
  • domain.com/site2/
  • domain.com/site3/

我正在使用 Statamic 提供的 NGINX conf:

https://gist.github.com/jackmcdade/3866603

我已经这样修改了:

https://gist.github.com/LkeMitchll/b6d8aea6c0845e3a341f

一切正常,但是...

...当我导航到 domain.com/site1/_config/users/admin.yaml 我可以不受限制地下载文件!(!!)

有问题的 NGINX 配置行是:

location ~ /.(yml|yaml|html) { deny all; }

我尝试了以下方法,但没有成功:

location ~ /(site1|site2|site3)/.+\.(yml|yaml|html) { deny all; }

老实说,我在 NGINX 是个十足的 n00b,事实证明它比 Apache 更难使用。

所以我的问题是如何修改上述语句以限制对 .yaml 和 .html 文件的访问?

谢谢。

LM

【问题讨论】:

    标签: php nginx virtualhost statamic


    【解决方案1】:

    试试这个。它需要一个$ 来匹配字符串的结尾。

    location ~* (?:\.(?:yml|yaml|html)|~)$ {
        deny all;
    }
    

    【讨论】:

    • 编辑:工作!抱歉,忘记清除缓存。谢谢!
    猜你喜欢
    • 2019-05-15
    • 2015-05-21
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多