我想用来.htaccess防止目录列表.
我在/ location /中有页面,但我没有索引文件.所以我想重定向到/location/about.php例如.
有没有办法做到这一点,没有创建index.html并将请求重定向到那?
谢谢您的帮助!
如果你要求一个文件代替'index.html',请参阅" DirectoryIndex "告诉它使用哪些文件代替'index.html':
DirectoryIndex about.php index.html
Options –Indexes
Run Code Online (Sandbox Code Playgroud)
...如果您尝试将所有目录重定向到单个页面,那么我会欺骗并执行以下操作,这将主要执行您要求的操作:
Options +Indexes
IndexOptions +SuppressHTMLPreamble
IndexIgnore *
HeaderName /includes/header.html
ReadmeName /includes/readme.html
Run Code Online (Sandbox Code Playgroud)
...并使用您想要的任何消息(或包含元重定向)设置/includes/header.html,并将/includes/readme.html设置为空白.
我知道这是一个较旧的线程,但我只需要实现类似的东西并按以下方式执行:
Options -Indexes
ErrorDocument 403 /location/about.php
Run Code Online (Sandbox Code Playgroud)
基本上,Options -Indexes阻止目录列表并ErrorDocument 403重写默认的403消息.
| 归档时间: |
|
| 查看次数: |
8395 次 |
| 最近记录: |