GoDaddy与目录问题(与“webroot”和“root”不同) [英] GoDaddy issues with directory (differences with "webroot" and "root")

查看:149
本文介绍了GoDaddy与目录问题(与“webroot”和“root”不同)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GoDaddy上,我有一个Linux主机帐户。当我编写网站时,如果我在我的链接中使用 /news/news.php ,我会收到一个错误页面,或者如果它是一个包含的页面,我会收到所有错误某些部分显示在页面上(我的页面的唯一部分不在包含中)。



我帐户的实际根目录是普通的Linux根目录,只能通过SSH访问;否则,我只能访问他们称之为webroot的东西(这不是文件夹或符号链接或任何可悲的-.-)。看看我的页面harrimanpcrepair.com,你可以在后台看到每个包含的这两个错误:

 警告:包含(/layoutIncludes/header/header.php)[function.include]:无法打开流:第25行/home/content/70/11248470/html/news/news.php中没有此类文件或目录

警告:include()[function.include]:无法在/ home中打开'/layoutIncludes/header/header.php'(include_path ='。:/ usr / local / php5_3 / lib / php')第25行/content/70/11248470/html/news/news.php

如果我尝试和使用 /home/content/70/11248470/html/news/news.php 和我所有东西的等价物,我想回​​到webroot所以我可以做所有我包括工作。但我不喜欢这样很混乱,看起来不正确。



有没有人遇到类似这样的事情?任何解决方案的工作?我不想继续使用 ../../../ 来通过目录,因为每次我复制并粘贴布局时都必须更改它。我可以在所有内容之前添加类似5 ../ 的内容,然后输入指向webroot所有内容的链接(因为它不会比服务器上的webroot更远,而不仅仅是斜线开始,但这会导致问题 - .-),但它很混乱,我试图让我的代码易于阅读和清理。

解决方案

请尝试以下操作:

 <?php include($ _ SERVER [DOCUMENT_ROOT]。'/ path /到/ file.php'); ?> 

或者:

 <?php include(dirname(__ FILE __)。'/ path / to / file.php'); ?> 


On GoDaddy I have a Linux hosting account. When I am coding a website, if I use in my links /news/news.php, I get an error page, or if it's an included page, I get errors all over the page while certain parts show (the only part of my page not in an include).

The actual root of my account is a normal Linux root directory only accessible by means of SSH; otherwise, I can only access what they call the webroot (which isn't a folder or symlink or anything sadly -.- ). Looking at my page harrimanpcrepair.com, you can see in the background I have these two errors for each include:

Warning: include(/layoutIncludes/header/header.php) [function.include]: failed to open stream: No such file or directory in /home/content/70/11248470/html/news/news.php on line 25

Warning: include() [function.include]: Failed opening '/layoutIncludes/header/header.php' for inclusion (include_path='.:/usr/local/php5_3/lib/php') in /home/content/70/11248470/html/news/news.php on line 25

If I try and use /home/content/70/11248470/html/news/news.php and the equivalent for all my stuff, I want to go back to the webroot so I can make all my includes work. but I don't like this it's messy and doesn't look right.

Has anyone ever ran into anything like this? Any solutions that work? I don't want to keep using ../../../ to get through directories because I have to change it every time I copy and paste my layout. I could just add like 5 ../ before everything and then type the link to everything from webroot (because it won't go farther back than webroot on the server without just a slash to start, but that causes problems -.-), but it's messy and I try to keep my code easy to read and clean.

解决方案

Try the following:

<?php include($_SERVER["DOCUMENT_ROOT"].'/path/to/file.php'); ?>

Or:

<?php include(dirname(__FILE__).'/path/to/file.php'); ?>

这篇关于GoDaddy与目录问题(与“webroot”和“root”不同)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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