【问题标题】:is there any way to use domain file in subdomain to?有没有办法在子域中使用域文件?
【发布时间】:2015-12-05 06:42:51
【问题描述】:

我的网站有一个子域,例如 domian.com 和 forum.domain.com。
在我的 domain.com 中,我有 inc 文件夹,其中包含我的 initialize.php 和 config.php 我的类和函数。我只是在每个 php 页面中包含 initialize.php 以及在 initialize.php 中包含的其他页面,如 config.php
在 config.php 我定义

define("BASE_URL","/");
define("ROOT_PATH",$_SERVER['DOCUMENT_ROOT']."/")

现在,当我在子域中包含初始化时,它不起作用,因为 ROOT_PATH 假定为子域。在这种情况下我该怎么办?如何在子域中使用 domian.com 根目录中的文件?
我应该将它们全部复制到子域中吗?

【问题讨论】:

    标签: php path


    【解决方案1】:

    可以通过如下简单的技巧来完成,

    <?php
    include_once $_SERVER['DOCUMENT_ROOT'] .  '/../inc/header.php';
    

    我建议您阅读以下教程 https://developer.hyvor.com/php/including-files-in-root-with-subdomain.php

    【讨论】:

      猜你喜欢
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-15
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 2018-01-28
      • 2011-04-17
      相关资源
      最近更新 更多