将子目录视为 xampp 中的 Web 根目录

Evi*_*l E 1 windows-7 apache-http-server xampp hosts-file

我在 Windows 7 机器上运行 Xampp。我有一个网站,它在我的 Web 根目录中运行。我通过以下方式访问该网站http://localhost/foobar

我想设置它,以便我可以指向我的本地浏览器说http://foobar,并让它将 foobar 目录视为 Web 根目录。

这是更改 apache 上的主机文件或配置的问题吗?

小智 7

要让浏览器http://foobar在本地计算机上查找,您必须将此行添加到主机文件中

127.0.0.1 foobar
Run Code Online (Sandbox Code Playgroud)

然后在你的 Apache http.conf 文件中添加一个虚拟主机,

<VirtualHost *:80>
    DocumentRoot path/to/foobar
    ServerName foobar
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

您可能还需要添加另一个虚拟主机

<VirtualHost *:80>
    DocumentRoot path/to
    ServerName localhost
ServerAlias 127.0.0.*
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)