PHP XAMPP Server DOCUMENT_ROOT 文件夹结构 [英] PHP XAMPP Server DOCUMENT_ROOT folder structure

查看:31
本文介绍了PHP XAMPP Server DOCUMENT_ROOT 文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我第一次使用 xampp 创建测试站点.我最初将所有 php 文件放在一个文件夹中,最近才决定组织数据(是的,事后看来我应该从有组织的文件夹结构开始.)无论如何,我的设置如下:

So this is my first time creating a test site with xampp. I originally had all my php files in one folder and just recently decided to organize the data (yes, hindsight i should've started with an organized folder structure.) Anyways, I have my setup like this:

" [ ] " 表示它是一个文件夹

" [ ] " implies it is a FOLDER

安装在我的 C:\ 驱动器上

Installed on my C:\ drive

[xampp]
└── [htdocs]
    └── [QMS]
        └── [rev3]
            ├── [css]
            ├── [js]
            ├── [DPU]
            ├── [login]
            ├── index.php
            ├── header.php
            └── config.php

在我的config.php"文件中,我试图定义一个根路径(这可能是错误):

In my "config.php" file I tried to define a root path (this may be the error):

$path = $_SERVER['DOCUMENT_ROOT'] . "/QMS/rev3/";

.

然后在我的 header.php 文件中:

Then in my header.php file I have:

<?php
require $_SERVER['DOCUMENT_ROOT'] . "/QMS/rev3/config.php";
include $_SERVER['DOCUMENT_ROOT'] . "/QMS/rev3/login/session.php";
.....
?>

HTML - located in the <head> section

<link rel='stylesheet' type='text/css' href='<?php echo $path . "css/searchBar.css"; ?>'/>
<link rel='stylesheet' type='text/css' href='<?php echo $path . "css/tables/filtergrid.css"; ?>'/>
<script type="text/javascript" language="javascript" src='<?php echo $path . "js/jquery.dataTables.js" ?>'></script>
<script type="text/javascript" language="javascript" src='<?php echo $path . "js/jquery.loader.js" ?>'></script>

... MANY OTHER scripts and stylesheets.

.我的 index.php 是:

. My index.php is:

require $_SERVER['DOCUMENT_ROOT'] . "/QMS/rev3/header.php";

当我在 Chrome 中启动它时 - 我的所有脚本和样式表都出现以下错误(总共 19 个错误):

When I launch this in Chrome - I get the following errors for ALL of my scripts and stylesheets (19 errors total):

"NOT ALLOWED TO LOAD LOCAL RESOURCE  file///C:/xampp/htdocs/QMS/rev3/ ......etc..."

当我的所有文件都在同一个文件夹中并且我没有使用 SERVER['DOCUMENT_ROOT'] 时,我的网站运行良好,但现在我不知道该怎么做...有什么建议吗?

My site was working perfectly when all my files were in the same folder and I wasn't using SERVER['DOCUMENT_ROOT'], but now I have no idea what to do...any advice?

.

推荐答案

不允许加载本地资源

您在

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆