Xampp本地主机/仪表板

4
我下载了最近的xampp版本并安装了它,但是当我在浏览器中输入“localhost”时,它会将我重定向到localhost/dashboard。有没有办法像以前那样键入localhost并查看目录和文件?
有一些xampp版本,你只需要更改index.php的名称或删除它,就可以从浏览器中看到localhost中的目录和文件。
是否有人知道是哪些版本?或者如何解决这个问题?

2
你需要编辑PHP配置文件。 - TarangP
安装完成后,你是否启动了XAMPP(Apache/MySQL)? - Niklesh Raut
6个回答

5
如果想显示目录,则需编辑 htdocs/index.php 文件。
以下代码会将所有目录以表格形式展示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Welcome to Nims Server</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="server/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- START PAGE SOURCE -->
<div id="wrap">
  <div id="top">
    <h1 id="sitename">Nims <em>Server</em> Directory list</h1>
    <div id="searchbar">
      <form action="#">
        <div id="searchfield">
          <input type="text" name="keyword" class="keyword" />
          <input class="searchbutton" type="image" src="server/images/searchgo.gif"  alt="search" />
        </div>
      </form>
    </div>
  </div>

<div class="background">
<div class="transbox">
<table width="100%" border="0" cellspacing="3" cellpadding="5" style="border:0px solid #333333;background: #F9F9F9;"> 
<tr>
<?php
//echo md5("saketbook007");

//File functuion DIR is used here.
$d = dir($_SERVER['DOCUMENT_ROOT']); 
$i=-1;
//Loop start with read function
while ($entry = $d->read()) {
if($entry == "." || $entry ==".."){
}else{
?>
<td  class="site" width="33%"><a href="<?php echo $entry;?>" ><?php echo ucfirst($entry); ?></a></td>  
<?php 
}
if($i%3 == 0){
echo "</tr><tr>";
}
$i++;
}?>
</tr> 
</table>

<?php $d->close();
?> 

</div>
</div>
</div>
   </div></div></body>
</html>

样式:

@import url("fontface.css");
* {
    padding:0;
    margin:0;
}
.clear {
    clear:both;
}

body {
    background:url(images/bg.jpg) repeat;
    font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
    color:#212713;
}
#wrap {
    width:1300px;
    margin:auto;
}

#sitename {
    font: normal 46px chunk;
    color:#1b2502;
    text-shadow:#5d7a17 1px 1px 1px;
    display:block;
    padding:45px 0 0 0;
    width:60%;
    float:left;
}
#searchbar {
    width:39%;
    float:right;
}
#sitename em {
    font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
}
#top {
    height:145px;
}
img {

    width:90%;
    height:250px;
    padding:10px;
    border:1px solid #000;
    margin:0 0 0 50px;
}


.post h2 a {
    color:#656f42;
    text-decoration:none;
}
#searchbar {
    padding:55px 0 0 0;
}
#searchfield {
    background:url(images/searchbar.gif) no-repeat;
    width:239px;
    height:35px;
    float:right;
}
#searchfield .keyword {
    width:170px;
    background:transparent;
    border:none;
    padding:8px 0 0 10px;
    color:#fff;
    display:block;
    float:left;
}
#searchfield .searchbutton {
    display:block;
    float:left;
    margin:7px 0 0 5px;
}

div.background
{
  background:url(h.jpg) repeat-x;
  border: 2px solid black;

  width:99%;
}
div.transbox
{
  margin: 15px;
  background-color: #ffffff;

  border: 1px solid black;
  opacity:0.8;
  filter:alpha(opacity=60); /* For IE8 and earlier */
  height:500px;
}

.site{

border:1px solid #CCC; 
}

.site a{text-decoration:none;font-weight:bold; color:#000; line-height:2}
.site:hover{background:#000; border:1px solid #03C;}
.site:hover a{color:#FFF}

输出: 这里输入图片描述

谢谢。我尝试修改index.php文件,但似乎不起作用。我想我的代码有问题。这个方法可行。 - Alberto
欢迎 @Alberto :) - Nims Patel

4

想要获取xampp文件夹列表吗?

只需删除或更改文件index.php为index.txt即可。然后,在浏览器中输入url:localhost,您就可以获得该列表。

Browser screenshot


0

只需创建文件index.php并将其保存到:C:\xampp\htdocs\

像用户Matiur Rahman一样。谢谢,对我很有效。您可以复制此脚本并将其粘贴到您的index.php文件中。

<?php
   if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
    $uri = 'https://';
   } else {
    $uri = 'http://';
   }
    $uri .= $_SERVER['HTTP_HOST'];
   header('Location: '.$uri.'/dashboard/');
   exit;
?>

0
尝试这个解决方案:
前往->
1. xammp ->htdocs->然后从htdocs文件夹中打开index.php文件 2. 您可以修改仪表板 3. 重新启动服务器
示例代码index.php:
    <?php
    if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
        $uri = 'https://';
    } else {
        $uri = 'http://';
    }
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/dashboard/');
    exit;
   ?>

0
这里是实际发生的情况 localhost 意味着您想要打开 htdocs。 首先,它会搜索任何名为 index.php 或 index.html 的文件。如果其中一个存在,它将打开该文件。 如果两者都不存在,则会打开 htdocs 目录中的所有文件夹/文件,这正是您想要的。
因此,最简单的解决方案是将 index.php 或 index.html 重命名为 index2.php 等。

0

在浏览器地址栏中输入您的URL localhost/[htdocs文件夹中的名称]


是的,我知道,但我想在URL中键入“localhost”并显示所有文件和目录,而不是键入整个URL,谢谢。 - Alberto

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接