phpstudy打开localhost总是自动跳转到localhost⼀index.html是怎么回事

2025-04-18 18:54:45
推荐回答(3个)
回答(1):

  • 是 phpstudy 搭建的服务器站点根目录下,缺少名为 index.html 的文件。服务器都会设置一个默认的访问主页文件,如图

  • 调整前后顺序,将 index.php 放前面。默认打开文档是根据上面的文件名顺序来完成搜索的,先搜索第1个,如果没找到,再搜索后面的。如果 index.php 放前面,先打开的就是 index.php。

  • wampserver打开localhost显示域名重定向怎么办?localhost显示域名重定向解决办法

  • 原代码:

  • while (($file = readdir($handle))!==false) 
    {
    if (is_dir($file) && !in_array($file,$projectsListIgnore)) 
    {
    //[modif oto] Ajout éventuel de http:// pour éviter le niveau localhost dans les url
    $projectContents .= '

  • '.$file.'
  • ';
    }
    }

  • 修改后代码:

  • while (($file = readdir($handle))!==false) 
    {
    if (is_dir($file) && !in_array($file,$projectsListIgnore)) 
    {
    //[modif oto] Ajout éventuel de http:// pour éviter le niveau localhost dans les url
    $projectContents .= '

  • '.$file.'
  • ';
    }
    }

回答(2):

从截图看,是 phpstudy 搭建的服务器站点根目录下,缺少名为 index.html 的文件。


通常情况下,服务器都会设置一个默认的访问主页文件,如下图所示:


回答(3):

因为你的web服务器上设置了默认打开网页index.html