简体   繁体   English

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

[英]Deny direct access except for the files and subdirectories with rewritten urls without file types

How can I prevent users from accessing a directory directly without preventing the files and sub directories being accessed? 如何防止用户直接访问目录而又不阻止文件和子目录的访问? Please note that all my pages are written in php and the file type .php is omitted using htaccess url rewrites. 请注意,我所有的页面都是用php编写的,而使用htaccess url重写则省略了.php文件类型。

When I tried to attain waht I need using the following htaccess lines, I get 403 errors for all my url's, as they do not have a file type in them. 当我尝试达到以下目的时,我会使用以下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>

The .htaccess file is in the dir folder .htaccess文件在dir文件夹中

When try to access http://www.domain.com/dir/sub/page I get a 403 error. 尝试访问http://www.domain.com/dir/sub/page出现403错误。 But when I try to access http://www.domain.com/dir/sub/page.php (note the .php file type) everything works fine. 但是,当我尝试访问http://www.domain.com/dir/sub/page.php (注意.php文件类型)时,一切正常。 How can I restrict the prohibition ONLY to DIRECTORIES, with respect to my rewrite rules? 就我的重写规则而言,如何将禁止范围仅限制在目录中?

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. 我需要访问的目录和子目录内任何苍蝇

Related questions like this and this did not help me since the omission of file type was not applicable to those. 像相关问题, 并没有帮助我,因为文件类型的不作为是不适用的。

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

You can try following rule: 您可以尝试以下规则:

# disable directory listing
Options -Indexes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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