$ _SERVER ['DOCUMENT_ROOT'] [英] $_SERVER['DOCUMENT_ROOT']

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

问题描述

首先,如果您阅读此书,请先感谢您的耐心等待,我是PHP的新手,我有一个问题要尝试解释/描述.

First of all, if you read this, thank you in advance for your patience,- I'm fairly new at PHP and have an issue which I will try to explain/describe.

//set default path
///var/www/vhosts/www.mydomain.com/httpdocs/
$url = 'http://mydomain.com/skins/coolblue/tmp';
$url2 = 'http://mydomain.com/skins/coolblue/tmp';
$doc = $_SERVER['DOCUMENT_ROOT'];
$path = '/templates/';
$actual_url = $doc.'/skins/coolblue/tmp'.$path;

(我最初有一个开发人员来构建我的网站并配置我的服务器,但他现在已经离开了) 我的网站托管在带有plesk控制面板的专用服务器上,因此当我打电话给Godaddy并询问他们['DOCUMENT_ROOT']的值时,他们给了我 */var/www/vhosts/www.mydomain.com/httpdocs/*

(I had a developer originally build my site and configure my server, but he's gone now) my site is hosted on a dedicated server with plesk control panel, so when I called Godaddy and asked them the value for ['DOCUMENT_ROOT'], they gave me * /var/www/vhosts/www.mydomain.com/httpdocs/*

我的问题是,我使用动态网址,例如subdomain.mydomain.com(已配置并正常工作),它反过来确定内容,并且输出是使用上述$_SERVER['DOCUMENT_ROOT']的特定脚本生成的,则该网址始终是www.++++格式的静态网址.我希望网址是动态的.

my issue is, I use dynamic urls eg subdomain.mydomain.com(which is already configured and works properly), which in turn determines content, and being that the output comes from a particular script using the $_SERVER['DOCUMENT_ROOT'] as above, the url is always the static url in the www.++++ format. I want the url to be dynamic.

是否可以解决此问题,还是可以将$ doc = $_SERVER['DOCUMENT_ROOT'];更改为脚本的实际URL,并添加动态域变量(即http://$subdomain/domain.com)?我试过了几乎所有的变种方式,但都没有碰到运气.你有什么建议吗?顺便说一句,$doc = $_SERVER['DOCUMENT_ROOT'];是必要的,还是由开发人员选择而不是写出路径? -再次谢谢你

Is there a way to go around this, or can I change the $doc = $_SERVER['DOCUMENT_ROOT']; to the actual url of the script and add in the dynamic domain variable ie http://$subdomain/domain.com? I have tried just about every variation of the path with no luck. Do you have any suggestions? As an aside, is $doc = $_SERVER['DOCUMENT_ROOT']; a necessary, or was it the choice of the developer instead of writing the path out? - Thank you again

推荐答案

$_SERVER['DOCUMENT_ROOT']是路径.请尝试使用'SERVER_NAME''REQUEST_URI'

$_SERVER['DOCUMENT_ROOT'] is path., try using 'SERVER_NAME' or 'REQUEST_URI'

"SERVER_NAME"

'SERVER_NAME'

正在执行当前脚本的服务器主机的名称.如果脚本在虚拟主机上运行,​​则将是为该虚拟主机定义的值.

The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

'REQUEST_URI'

'REQUEST_URI'

为访问该页面而给出的URI;例如'/index.html'.

The URI which was given in order to access this page; for instance, '/index.html'.

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

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