.htaccess: prevent access to files and prevent directory browsing

后端 未结 2 1719
挽巷
挽巷 2021-01-23 00:37

I want to prevent all file access and directory browsing for a directory without putting a .htaccess file in said directory.

For example, let\'s say this is in my root w

相关标签:
2条回答
  • 2021-01-23 01:35

    Enable mod_rewrite with

    $ sudo a2enmod rewrite
    

    Append this to your .htaccess;

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^myframework/ - [F,L]
    </IfModule>
    
    0 讨论(0)
  • 2021-01-23 01:38

    Have this code in your DOCUMENT_ROOT .htaccess file

    Options +FollowSymlinks -MultiViews
    
    RewriteEngine On
    RewriteRule ^myframework/ - [NC,F,L]
    
    • NC - Ignore Case comparison
    • F - Mark current URI Forbidden
    • L - Mark this rule as last
    0 讨论(0)
提交回复
热议问题