【问题标题】:How to access the directories outside the subdomain folder如何访问子域文件夹之外的目录
【发布时间】:2014-04-28 08:20:19
【问题描述】:

如何访问子域文件夹之外的文件夹。

例如,我的域是localhost,我有一个子域m.localhost。他们的文件夹是:

Server Root:
    /cdn/
    /contents/
    /mobile/
    .htaccess

而文件夹/mobile/是我的m.localhost的根目录。从m.localhost,如何使用PHP 访问/contents/ 目录及其内容?

$_SERVER['DOCUMENT_ROOT'] 只选择子域目录根目录。

【问题讨论】:

    标签: php apache subdomain document-root


    【解决方案1】:

    试试这个。

    realpath(dirname(__FILE__).'/../../../contents/nav/quicklinks.txt');
    

    【讨论】:

    • 好吧,我试图在/contents/ 文件夹中获取文件的内容并将其存储为变量。我想实现:$quicklinks = file_get_contents(realpath(dirname(__FILE__).'/../contents/nav/quicklinks.txt'));,但我收到了这个错误:Warning: file_get_contents(): Filename cannot be empty in C:\XAMPP\htdocs\mobile\cdn\php\nav.php on line 5。如何解决?
    • @KevinHandogTresuelo 由于您从移动文件夹的子目录调用脚本,它不起作用。我已经更新了我的答案。
    • @KevinHandogTresuelo 欢迎您。如果对您有帮助,请不要忘记 +1。
    • @KevinHandogTresuelo 谢谢。
    • 有没有办法让/../../../contents/nav/quicklinks.txt 成为绝对网址?好像只是/contents/nav/quicklinks.txt
    猜你喜欢
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-28
    相关资源
    最近更新 更多