更改Web根目录中的Apache(XAMPP) [英] change the web root directory in apache (xampp)

查看:104
本文介绍了更改Web根目录中的Apache(XAMPP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在XAMPP运行本地主机回声PHP_SELF,我得到的项目文件夹中回应文本例如

When I echo "PHP_SELF" in localhost running on xampp, I get the project folder as the echoed text e.g.

// index.php

<?php echo $_SERVER["PHP_SELF"]; ?>

答案是:

/a3-ver-9.0/index.php

/a3-ver-9.0/index.php

但是,如果我是一个域中的服务器上,这条线将只返回/ index.php文件

but if I was on a server with a domain, that line would just return "/index.php"

有什么办法,我可以暂时改变默认的根XAMPP来反映这一点?

Is there any way I can temporarily changes the default root in xampp to reflect this?

的原因是因为我使用从根绝对路径,包括资源,例如图像。
然而,如果根没有正确设置这些绝对路径是行不通的!

The reason is because I use absolute paths from root to include resources e.g. images. however these absolute paths will not work if the root is not set correctly!

干杯

修改

为了让事情更清晰...

To make things more clear...

我有一个PHP文件返回的页面例如部分网站header.php文件和footer.php等。

I have a website with php files that return parts of the page e.g. header.php and footer.php etc.

我有一句话preSS的安装,并在字preSS模板,包括我这些文件。因为IM包括来自不同的目录中这些文件,包含文件内的路径必须是绝对的。

I have an installation of wordpress and in the wordpress template, I include these files. and because im including these files from different directories, the paths inside the included files must be absolute.

然而,在在header.php文件都包括在内,如:

however the files in the header.php are included like:

<img src="/images/image1.jpg" />

现在这包括是正确的,当我完成了这个项目,并把它上传到我的服务器,将正确检索图像。

now this include is correct, and when I've finished the project and upload it to my server it will correctly retrieve the image.

但本地主机工作时,根文件夹/是所有我的地方项目保存的文件夹。当

but when working with localhost, the root folder "/" is the folder where ALL my local projects are kept.

所以,我需要一种方法来临时更改每个项目的本地主机的根,所以我不必须要改变的路径的负载乱当项目准备上传!

So i need a way to temporarily change the localhost root for each project, so i dont have to mess about changing a load of paths when the project is ready for upload!

希望这会更有意义。

不过本地主机上工作时

推荐答案

要解决这个问题最好的办法就是在本地使用虚拟主机为您的项目。
因此,像www.project.local实际显示您的项目。

Best way to solve this is using virtual hosts for your projects locally. So something like www.project.local actually shows your project.

这里是一个教程如何在XAMPP实现这一目标。

Here is a tutorial how to achieve this in xampp.

这篇关于更改Web根目录中的Apache(XAMPP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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