【发布时间】:2015-10-16 15:39:18
【问题描述】:
我正在尝试制作可在我的本地服务器和我的实际网站服务器上运行的可靠代码,因此我不必更改文件的路径等。我不能使用相对路径,因为我使用的是子域,所以浏览器看不到该路径上方的文件夹,所以我想做的是在我的本地服务器上使用根文件夹来指导我的代码文件所在的位置和网络服务器上我检索服务器名。我现在得到的错误是
Warning: include(http://cms.domain.com/serverdetails.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/html/domain/administration/cms/DBconnection_patches.php on line 11
我有一个主域和一个带有 cms 文件的子域 cms.domain 的结构是这样的
domain
-index.php
-js
-files.js
-administration (subdomain folder)
-index.php
-otherfiles.php
这是一个通过Vhost制作的普通子域,在linux ubuntu 14.04 apache2上。
if($_SERVER['SERVER_NAME']=='domain.com'){
$local = false;
}elseif($_SERVER['SERVER_NAME']=='localhost'){
$local = true;
}
if($local){
include $_SERVER['DOCUMENT_ROOT'] . '/domain/administration/serverdetails.php';
}else{
include 'http://cms.'.$_SERVER['SERVER_NAME'] . '/serverdetails.php';
}
【问题讨论】:
标签: php html directory apache2