简体   繁体   中英

How can I stop users from viewing folders that have no index page but other pages on my web site using PHP or mod rewrite?

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:

http://httpd.apache.org/docs/1.3/mod/core.html#directory

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