I'm using WAMP.
I have 10+ folders in my "www\mystuffs" folder. I have folder called temp. How do I hide th开发者_如何学Gois folder from directory listing and create a link to access files in that folder...?
If you use listing created by apache, you can hide it by adding this to .htaccess file in "www\mystuffs\"
IndexIgnore temp
Then you can link to that folder directly, and it should list everything inside.
Just create a index.php in that directory with a link to list out all the files in that folder. You can do so by using following code.
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<a href='$file'>$file</a>\n";
}
}
closedir($handle);
}
?>
I have 10+ folders in my "www\mystuffs" folder. I have folder called temp. How do I hide this folder from directory listing
http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html#indexignore
Create a file named ".htaccess" in folder \www\mystuffs.
Within this file add line:
IndexIgnore temp
This will cause Apache to not display this folder.
Note that:
- The documentation states this works on files only. This is not true and will work to hide directories/folders.
- You have to create an ".htaccess" file through an editor as Windows won't allow a file name to start with "." when creating this file through the Windows Explorer.
... and create a link to access files in that folder...?
You can either have a directory listing via Apache of the entire folder, or create your own index.html file... You can't insert your own links into that original listing.
What you can do is allow that listing of the temp folder, and in that folder create an "index.html" file with the listing of whatever files you want the user to see.
精彩评论