$ _SERVER ['document_root']返回/htdocs而不是/public_html [英] $_SERVER['document_root'] returns /htdocs not /public_html

查看:94
本文介绍了$ _SERVER ['document_root']返回/htdocs而不是/public_html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找切换到新主机的方法,他们提供了这个不错的小临时URL"来在切换之前测试您的文件.一切都好,花花公子.因此,我复制了所有文件.在每个页面的顶部,我require来自服务器的另一个文件,存储在public_html/includes/head.php.现在,无论出于何种原因,$ _ SERVER ['document_root'] var返回/public_html/htdocs/includes/head.php(服务器上不存在)而不返回/public_html/includes/head.php(确实存在) .产生的错误如下:

I'm looking to switch over to a new host, and they provide this nice little "temporary url" to test out your files before you switch. All fine and dandy. So I copy over all of my files. At the top of every page I require another file from the server that is stored at public_html/includes/head.php. Now for whatever reason, the $_SERVER['document_root'] var is returning /public_html/htdocs/includes/head.php (which does not exist on the server) and not /public_html/includes/head.php (which does exist). The resulting error is as follows:

Warning: require_once(/home/secure31/public_html/htdocs/includes/head.php) 
[function.require-once]: failed to open stream: Permission denied in 
/home/stephe80/public_html/index.php on line 6

有罪代码:

require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/head.php');

我倾向于认为这是与其临时URL设置相关的错误,但是我不想通过DNS传输并发现我的所有文件都已损坏.我可以将它们更改为绝对路径,但对于是否缺少某些东西感到好奇.任何见识将不胜感激.谢谢!

I am inclined to think that this is an error associated with their temporary url setup, but I do not want to transfer over my DNS and find that all of my files are broken. I could change them to absolute paths, but I am curious as to whether I am missing something. Any insight would be appreciated. Thanks!

推荐答案

对于以后的参考(如果有人遇到类似的问题),事实证明问题出在他们的测试服务器上.我以我的代码原样启动了它(我知道它是危险的),而且一切都很好.

For future reference (if anyone has similar issues), it turns out that the problem was with their test server. I launched it with my code as-was (risky, I know), and all turned out well.

这篇关于$ _SERVER ['document_root']返回/htdocs而不是/public_html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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