为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
LEATH 2023-04-21 10:17:32
您好我已经浏览了所有资源,但似乎仍然找不到解决方案。我的计算机上安装了 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这是我的站点目录的结构为了避免缓存,我以隐身模式和不同的浏览器打开 URL。我总是重定向到仪表板 - https://ikeen.localhost/dashboard/,它打开标准的“欢迎使用 Windows 7.4.3 XAMPP”听说跟https有关系,我用http也总是转到https url。我查看了 httpd-ssl.conf,但我不知道在那里做什么。有任何想法吗?
查看完整描述

3 回答

?
茅侃侃

TA贡献1842条经验 获得超21个赞

最后!对于正在寻找解决方案的每个人,请执行以下操作:


我想要的站点位于 D:\xampp\htdocs\ikeen。


1) 将此添加到您的 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>

2) 将此添加到 httpd.conf 的末尾:


<Directory />

    AllowOverride none

    Require all granted

</Directory>

3) 将此行添加到 Windows 目录中的主机文件


127.0.0.1      ikeen.localhost

4) 最后,这是所有解决方案中都缺少的步骤。将此添加到您的 httpd-ssl.conf,在您的本地主机(通常是 www.example.com)的相同部分之后,将 example.com 更改为本地主机的本地设置,以便整个部分看起来像这样


<VirtualHost _default_:443>


#   General setup for the virtual host

DocumentRoot "D:/xampp/htdocs"

#ServerName www.example.com:443

ServerName localhost

ServerAdmin admin@example.com

ErrorLog "D:/xampp/apache/logs/error.log"

TransferLog "D:/xampp/apache/logs/access.log"


#   General setup for the ikeen host

DocumentRoot "D:/xampp/htdocs/ikeen"

#ServerName www.example.com:443

ServerName ikeen.localhost

ServerAdmin admin@example.com

ErrorLog "D:/xampp/apache/logs/error.log"

TransferLog "D:/xampp/apache/logs/access.log"


查看完整回答
反对 回复 2023-04-21
?
芜湖不芜

TA贡献1796条经验 获得超7个赞

我遇到过同样的问题。通过删除标准虚拟主机条目解决了问题,我没有被重定向到根目录。


只需删除这些代码行:


<VirtualHost *:80>

     ServerName localhost

     DocumentRoot "D:\xampp\htdocs"

     <Directory "D:\xampp\htdocs">

         DirectoryIndex index.php

     </Directory>

 </VirtualHost>


查看完整回答
反对 回复 2023-04-21
?
Cats萌萌

TA贡献1805条经验 获得超9个赞

如果这种情况不起作用,也许更改 httpd-ssl.conf


我的 3 个网站有效,localhost、test1.com、test2.com


#

<VirtualHost _default_:443>

DocumentRoot "c:/xampp/htdocs"

ServerName localhost

ServerAdmin admin@example.com

ErrorLog "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.com

ServerAdmin admin@example.com

ErrorLog "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.com

ServerAdmin admin@example.com

ErrorLog "c:/xampp/apache/logs/error.log"

TransferLog "c:/xampp/apache/logs/access.log"


...

</VirtualHost>   


查看完整回答
反对 回复 2023-04-21
  • 3 回答
  • 0 关注
  • 89 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信