Can I create private directory listings?
We have a page explaining how to display a listing of files for every visitor to a certain directory or folder URL address, which is a common request.
A more unusual request is “How can I see a directory listing, even though other people don’t see it?”
Options +Indexes DirectoryIndex disabled
Then within that new directory, use the command-line shell to create a symlink to the directory or directories you want to show listing for (which can even include the top level of your web site).
An example will probably help. Let’s say you want to have a way to view a directory listing of all your website files. You could use these commands after logging in to the shell:
cd html mkdir private-listings cd private-listings echo "Options +Indexes" >> .htaccess echo "DirectoryIndex disabled" >> .htaccess ln -s ../ all-files
After that, visiting http://example.com/private-listings/all-files/ will show you a directory listing of every file on your site.
Note that this setup will still run PHP script files as PHP programs, instead of showing you their source code or downloading them. If you want to change that, you could add this line to the .htaccess file:
AddHandler default php cgi
This will show you the source code of all files ending with “.php” and “.cgi” (which is a security risk: be very sure you’ve successfully password protected your directory to ensure hackers can’t view the source code of your files, which may contains passwords and other private information).
Copyright © 2000-2021 Tiger Technologies LLC