简体   繁体   中英

xampp showing folder empty in htdocs

I have a folder called myfiles in htdocs and this folder contains a file with name home.php. When I open http://localhost:8080/myfiles/ it was showing no files in it. After trying few things, somehow I get a thought of changing the file name to home1.php and then the file are being displayed. 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.

If you will check xampp/apache/httpd.conf file you will find the following code

<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.

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.

Please find that module and add the file name home.php from that module and everything will work fine.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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