繁体   English   中英

拒绝直接访问,但带有重写的url且没有文件类型的文件和子目录除外

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM