通过重定向preventing目录列表? [英] Preventing directory listing by redirecting?

查看:135
本文介绍了通过重定向preventing目录列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用的.htaccess prevent目录列表。 我有内/位置页/但我没有一个索引文件。因此,林想重定向到/location/about.php为例。

I'm wanting to use .htaccess to prevent directory listing. I've got pages within /location/ but I don't have an index file. So Im wanting to redirect to /location/about.php for example.

有没有办法做到这一点,而无需创建一个index.html,然后将请求重定向到? 感谢您的帮助!

Is there a way to do this, without creating a index.html and redirecting requests to that? Thanks for the help!

推荐答案

如果你要求的地方的index.html',看到了一个文件的DirectoryIndex 告诉到位的index.html'的使用何种文件:

If you're asking for a file in place of 'index.html', see "DirectoryIndex" to tell it what files to use in place of 'index.html':

DirectoryIndex about.php index.html
Options –Indexes

...如果你想所有目录重定向到一个页面,然后我会欺骗和做到以下几点,这将主要是做你问的:

... if you're trying to redirect all directories to a single page, then I'd cheat and do the following, which will mostly do what you're asking for:

Options +Indexes
IndexOptions +SuppressHTMLPreamble
IndexIgnore *
HeaderName /includes/header.html
ReadmeName /includes/readme.html

...并设置/includes/header.html与任何消息,你想(或含元重定向),并/includes/readme.html是空白。

... and set /includes/header.html with whatever message you want (or containing a meta-redirect), and /includes/readme.html to be blank.

这篇关于通过重定向preventing目录列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆