I just wanted to know how to stop user from viewing folders without index pages using PHP or mod rewrite?
All of these answers are good but I will rate the one with the most votes.
Configure your web server to not automatically serve directory indexes.
Using Apache, this is done with the -Indexes
option :
<Directory /web/docs/spec>
Options -Indexes
</Directory>
You can also put this Options -Indexes
directive in an .htaccess
file in the specific directory.
You don't need PHP for this. Just put a blank index.html
in the directory.
By viewing folders, I assume there is a directory listing that you don't want visible. In that case, in your .htaccess file:
Options -Indexes
This can be done on a per-directory basis. See:
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.