.htaccess 文件。我可以阻止对目录的访问而不阻止对其中文件的访问吗?
我正在构建一个网站,但我不完全确定如何处理 .htaccess 文件。 举例来说,我有一个名为“pages”的文件夹,其中包含我的所有页面,如果某人输入 www.website.com/pages,我是否可以拒绝他们的访问,以便他们看不到该目录? 我尝试将 .htaccess 文件放入带有“拒绝所有”行的页面文件夹中,尽管它拒绝访问,但它也拒绝访问实际页面。 有没有办法做到这一点而不拒绝访问查看网站上的页面,而只是拒绝访问目录?
抱歉,如果这没有多大意义,我很困惑,哈哈。 感谢您的任何帮助。
I'm building a website, but I'm not entirely sure what to do with the .htaccess file.
Say for example I have a folder called pages which holds all my pages, can i deny access to someone if they type in www.website.com/pages so that they can't see the directory?
I've tried putting the .htaccess file in the pages folder with the "deny from all" line and although it denies access, it's also denying access to the actual pages.
Is there a way to do this without denying access to see the pages on the website, just denying access to the directory?
Sorry if this doesn't make much sense, I'm so confused lol.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您不希望 Apache 显示目录中的文件列表,可以使用
禁用
索引
功能。有关详细信息,请参阅 Apache 手册的 选项指令 部分。
否则,一种“简单的方法”就是只放置一个空的
index.html
或index.php
文件——即 Apache 在尝试时使用的默认文件。访问目录。关于这一点,请参阅 DirectoryIndex 指令。
If you don't want Apache to display the list of files in the directory, you can use
To disable the
indexes
feature.See the Options Directive section of Apache's manual, for more informations.
Else, an "easy way" would be to just put an empty
index.html
orindex.php
file -- i.e. a default file that Apache uses when one is trying to access a directory.About that, see the DirectoryIndex Directive.
只需在目录中放置一个空的index.html 即可。
Just put an empty index.html in the directory.
我使用过的大多数主机都使用
IndexIgnore *
指令来完成此操作。只需将其放入 .htaccess 文件中,然后将其放入您想要阻止索引的文件夹中。
更多信息:Apache IndexIgnore 文档。
Most hosts I've used do it with the
IndexIgnore *
directive.just put that in a .htaccess file and drop it into the folder you want to block indexing of.
More info: Apache IndexIgnore Documentation.
您可以登录站点管理器,然后可以使用索引管理器说出您想要保护的文件夹。我刚刚做了我的
You can log into your site manager and then you can use you index manager to say which folder you would like to protect. I just did mine