Apache configuration: Regex to disable access to files/directories beginning with a dot

后端 未结 4 1975
你的背包
你的背包 2021-01-31 18:00

I want to disable access to any file OR directory, whose name begins with a DOT. I came up with the following, but it disables access to files/directories beginning with DOT onl

4条回答
  •  余生分开走
    2021-01-31 18:45

    You code does not work because only applies to the basename of the requested document. That is, the part after the last slash. (source: http://httpd.apache.org/docs/current/mod/core.html#files)

    Apache blocks .htaccess files in a default installation (better: all files starting with .ht). If you looked closely at the configuration files, you would see something like this:

    
        Order allow,deny
        Deny from all
    
    

    So to hide all files starting with a dot, you would use:

    
        Order allow,deny
        Deny from all
    
    

    In order to make it work for directories starting with a dot, use the following (tested) code:

    
        Order allow,deny
        Deny from all
    
    

提交回复
热议问题