htaccess deny from all

前端 未结 3 1146
北荒
北荒 2020-12-13 23:34

I\'ve been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes which i didn\'t see anypoin

相关标签:
3条回答
  • 2020-12-14 00:03

    You cannot use the Directory directive in .htaccess. However if you create a .htaccess file in the /system directory and place the following in it, you will get the same result

    #place this in /system/.htaccess as you had before
    deny from all
    
    0 讨论(0)
  • 2020-12-14 00:12

    You can use from root directory:

    RewriteEngine On
    RewriteRule ^(?:system)\b.* /403.html
    

    Or:

    RewriteRule ^(?:system)\b.* /403.php # with header('HTTP/1.0 403 Forbidden');
    
    0 讨论(0)
  • 2020-12-14 00:14

    You can also use RedirectMatch directive to deny access to a folder.

    To deny access to a folder, you can use the following RedirectMatch in htaccess :

     RedirectMatch 403 ^/folder/?$
    

    This will forbid an external access to /folder/ eg : http://example.com/folder/ will return a 403 forbidden error.

    To deny access to everything inside the folder, You can use this :

    RedirectMatch 403 ^/folder/.*$
    

    This will block access to the entire folder eg : http://example.com/folder/anyURI will return a 403 error response to client.

    0 讨论(0)
提交回复
热议问题