[英]Deny direct access except for the files and subdirectories with rewritten urls without file types
如何防止用户直接访问目录而又不阻止文件和子目录的访问? 请注意,我所有的页面都是用php编写的,而使用htaccess url重写则省略了.php
文件类型。
当我尝试达到以下目的时,我会使用以下htaccess行,因为我的所有URL都没有文件类型,因此我收到403错误。
# Deny access to everything by default
Order Deny,Allow
deny from all
# Allow access to html files
<Files *.*>
allow from all
</Files>
.htaccess
文件在dir
文件夹中
尝试访问http://www.domain.com/dir/sub/page
出现403错误。 但是,当我尝试访问http://www.domain.com/dir/sub/page.php
(注意.php
文件类型)时,一切正常。 就我的重写规则而言,如何将禁止范围仅限制在目录中?
我只需要限制直接访问目录和子目录 。 我需要访问的目录和子目录内任何苍蝇 。
I need to restrict direct access only to directories and sub directories. I need to access whatever the flies inside the directories and sub directories.
What I meant was to prohibit directory listing. And show to 403 instead
您可以尝试以下规则:
# disable directory listing
Options -Indexes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.