虚拟主机无法在 XAMPP 上运行,发生了一些非常奇怪的事情

您好我已经浏览了所有资源,但似乎仍然找不到解决方案。


我的计算机上安装了 XAMPP Control Panel v 3.2.4(2019 年 6 月 5 日编译),它安装在 d:\xampp 中。我想创建一个虚拟主机,以便我可以正确使用各种全局 PATH 变量。


我严格按照说明进行操作。


这是来自我的 D:\xampp\apache\conf\extra\httpd-vhosts.conf:


    <VirtualHost *:80>

     ServerName localhost

     DocumentRoot "D:\xampp\htdocs"

     <Directory "D:\xampp\htdocs">

         DirectoryIndex index.php

     </Directory>

 </VirtualHost>


<VirtualHost *:80>

     ServerName ikeen.localhost

     DocumentRoot "D:\xampp\htdocs\ikeen"

     SetEnv APPLICATION_ENV "development"

     <Directory "D:\xampp\htdocs\ikeen">

         DirectoryIndex index.php

         AllowOverride All

         Order allow,deny

         Allow from all        

     </Directory>

 </VirtualHost>

我在 httpd.conf 的末尾添加了以下几行:


<Directory />

    AllowOverride none

    Require all granted

</Directory>

我在 Windows 的主机文件中有以下行:


127.0.0.1      ikeen.localhost

这是我的站点目录的结构

http://img.mukewang.com/6441f3a900014f9505110747.jpg

为了避免缓存,我以隐身模式和不同的浏览器打开 URL。我总是重定向到仪表板 - https://ikeen.localhost/dashboard/,它打开标准的“欢迎使用 Windows 7.4.3 XAMPP”

听说跟https有关系,我用http也总是转到https url。我查看了 httpd-ssl.conf,但我不知道在那里做什么。有任何想法吗?


LEATH
浏览 94回答 3
3回答

茅侃侃

最后!对于正在寻找解决方案的每个人,请执行以下操作:我想要的站点位于 D:\xampp\htdocs\ikeen。1) 将此添加到您的 httpd-vhosts.conf:<VirtualHost *:80>&nbsp; &nbsp; &nbsp;ServerName localhost&nbsp; &nbsp; &nbsp;DocumentRoot "D:\xampp\htdocs"&nbsp; &nbsp; &nbsp;<Directory "D:\xampp\htdocs">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DirectoryIndex index.php&nbsp; &nbsp; &nbsp;</Directory>&nbsp;</VirtualHost><VirtualHost *:80>&nbsp; &nbsp; &nbsp;ServerName ikeen.localhost&nbsp; &nbsp; &nbsp;DocumentRoot "D:\xampp\htdocs\ikeen"&nbsp; &nbsp; &nbsp;SetEnv APPLICATION_ENV "development"&nbsp; &nbsp; &nbsp;<Directory "D:\xampp\htdocs\ikeen">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DirectoryIndex index.php&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AllowOverride All&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Order allow,deny&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Allow from all&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;</Directory>&nbsp;</VirtualHost>2) 将此添加到 httpd.conf 的末尾:<Directory />&nbsp; &nbsp; AllowOverride none&nbsp; &nbsp; Require all granted</Directory>3) 将此行添加到 Windows 目录中的主机文件127.0.0.1&nbsp; &nbsp; &nbsp; ikeen.localhost4) 最后,这是所有解决方案中都缺少的步骤。将此添加到您的 httpd-ssl.conf,在您的本地主机(通常是 www.example.com)的相同部分之后,将 example.com 更改为本地主机的本地设置,以便整个部分看起来像这样<VirtualHost _default_:443>#&nbsp; &nbsp;General setup for the virtual hostDocumentRoot "D:/xampp/htdocs"#ServerName www.example.com:443ServerName localhostServerAdmin admin@example.comErrorLog "D:/xampp/apache/logs/error.log"TransferLog "D:/xampp/apache/logs/access.log"#&nbsp; &nbsp;General setup for the ikeen hostDocumentRoot "D:/xampp/htdocs/ikeen"#ServerName www.example.com:443ServerName ikeen.localhostServerAdmin admin@example.comErrorLog "D:/xampp/apache/logs/error.log"TransferLog "D:/xampp/apache/logs/access.log"

芜湖不芜

我遇到过同样的问题。通过删除标准虚拟主机条目解决了问题,我没有被重定向到根目录。只需删除这些代码行:<VirtualHost *:80>&nbsp; &nbsp; &nbsp;ServerName localhost&nbsp; &nbsp; &nbsp;DocumentRoot "D:\xampp\htdocs"&nbsp; &nbsp; &nbsp;<Directory "D:\xampp\htdocs">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DirectoryIndex index.php&nbsp; &nbsp; &nbsp;</Directory>&nbsp;</VirtualHost>

Cats萌萌

如果这种情况不起作用,也许更改 httpd-ssl.conf我的 3 个网站有效,localhost、test1.com、test2.com#<VirtualHost _default_:443>DocumentRoot "c:/xampp/htdocs"ServerName localhostServerAdmin admin@example.comErrorLog "c:/xampp/apache/logs/error.log"TransferLog "c:/xampp/apache/logs/access.log"...</VirtualHost>#test1<VirtualHost _default_:443>DocumentRoot "c:/xampp/htdocs/test1"ServerName test1.comServerAdmin admin@example.comErrorLog "c:/xampp/apache/logs/error.log"TransferLog "c:/xampp/apache/logs/access.log"...</VirtualHost>#test2<VirtualHost _default_:443>DocumentRoot "c:/xampp/htdocs/test2"ServerName test1.comServerAdmin admin@example.comErrorLog "c:/xampp/apache/logs/error.log"TransferLog "c:/xampp/apache/logs/access.log"...</VirtualHost>&nbsp; &nbsp;
打开App,查看更多内容
随时随地看视频慕课网APP