简体   繁体   English

xampp显示htdocs中的文件夹为空

[英]xampp showing folder empty in htdocs

I have a folder called myfiles in htdocs and this folder contains a file with name home.php. 我在htdocs有一个名为myfiles的文件夹,该文件夹包含一个名为home.php的文件。 When I open http://localhost:8080/myfiles/ it was showing no files in it. 当我打开http:// localhost:8080 / myfiles /时,它没有显示文件。 After trying few things, somehow I get a thought of changing the file name to home1.php and then the file are being displayed. 在尝试了几件事之后,我以某种方式想到将文件名更改为home1.php,然后显示文件。 I am not able to figure out this, that why this is so. 我不知道为什么,为什么会这样。 Can anybody put some light on this. 任何人都可以对此发表一些看法。

home.php is one of the default index page to show in apache settings. home.php是在Apache设置中显示的默认索引页面之一。

If you will check xampp/apache/httpd.conf file you will find the following code 如果您将检查xampp / apache / httpd.conf文件,则会找到以下代码

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule> 

If you want to remove home.php as index you need to delete it from the above code and then need to restart the apache. 如果要删除home.php作为索引,则需要从上述代码中将其删除,然后重新启动apache。

There can be many reasons for this, You might have turned off directory listing in your apache server for this file name in the "dir_module" of the apache server. 可能有许多原因,您可能已在apache服务器的“ dir_module”中为此文件名关闭了apache服务器中的目录列表。

Please find that module and add the file name home.php from that module and everything will work fine. 请找到该模块,并从该模块中添加文件名home.php,一切都会正常进行。

And if just listing files in that folder is only what is required then you can use this code: foreach($files as $file) { if( is_file($file) ) { //something } } taken from this link: PHP: How to list files in a directory without listing subdirectories I hope this helps. 如果只需要列出该文件夹中的文件,则可以使用以下代码: foreach($files as $file) { if( is_file($file) ) { //something } }从此链接中获取: PHP:如何列出目录中的文件而不列出子目录 ,希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM