I know this must be something around .htaccess or php.ini.
If a site visitor views ANY folder I want to automatically run a script listing the files in it (file_read.php).
But I only want the file_read.php to be in my root folder.
Can someone point me please?
Thanks.
Not so long ago I had similar problem and ended with
.htaccesslike this:Some explanation why like this:
RewriteCond %{REQUEST_FILENAME} -d– to make it work only on directoriesRewriteCond %{REQUEST_FILENAME}index.php !-f– do not list directories containiing index fileRewriteRule (.*/) file_read.php?dirpath=/$1– note the ending slash, without it enteringhttp://server.com/directory(no trailing slash) was redirected to something likehttp://server.com/directory/file_read.php?dirpath=directory, not exactly what we wanted.RewriteRule ^$ file_read.php?dirpath=/– after adding trailing slash to rule above, directory lister stopped working for root directory (http://server.com/) so this line fixes it