【问题标题】:Issues with back directories返回目录的问题
【发布时间】:2017-08-20 21:52:20
【问题描述】:

当我尝试使用 file_exists("test.xml") 访问文件时,如果它在同一目录中,它可以工作,但是如果我将文件放在 www 后面的目录中并尝试 file_exists("../test. xml") 它没有找到它

我检查以确保 www 目录不是快捷方式等,但我怀疑可能是 nginx 阻止了它?

【问题讨论】:

  • stackoverflow.com/questions/26520615/… 最佳做法是使用绝对路径作为 file_exists 路径。如果您使用绝对路径(正如我链接的问题中的第一个答案所暗示的那样),您还有这个问题吗?
  • 如果我执行像“/var/folder1/www/test.xml”这样的绝对路径,它适用于同一个文件夹,但如果我将 test.xml 放在 www 之外并使用相同的“/ var/folder1/test.xml" 它不起作用。我之前尝试过,但我再次尝试回答您的问题
  • 尝试编辑你的网络服务器配置,插入“php_admin_value open_basedir none”
  • 您必须进一步说明,究竟什么是 Web 服务器配置?我在哪里可以找到它?
  • @diavolic 指的是您的 Web 服务器配置中的一个设置,该设置将允许 PHP 访问目录树之外的文件(php.net/manual/en/ini.core.php 中的 Ctrl + open_basedir)。如果您启用了 mod_rewrite(但 nginx 不支持 mod_rewrite),您可以在 Apache 配置、php.ini 或 .htaccess 中执行此操作。抱歉,我无法提供更多帮助,我对 nginx 不是很熟悉。 stackoverflow.com/questions/13291185/…

标签: php nginx file-exists


【解决方案1】:

我的托管公司告诉我,我必须符号链接允许在 apache 或 .htaccess 中进行配置

这是https://httpd.apache.org/docs/2.2/mod/core.html的链接

我去了 /etc/apache2/conf-availabe/serve-cgi-bin.conf 并改变了这个

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

与

Options +ExecCGI -MultiViews Indexes FollowSymLinks

重新启动了 apache 和 nginx,但仍然没有,我有点绝望:/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多