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

后端 未结 4 1981
你的背包
你的背包 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 19:05

    With rewrite mod:

    RewriteEngine on
    
    RewriteCond %{THE_REQUEST} ^.*/\.
    RewriteRule ^(.*)$ - [R=404]
    

    Every file or dir who begin with a dot will be redirected to 404.

    /myDir/.svn => 404
    /.gitignore => 404
    /dir1/dir2/dir3/..../.toHide => 404
    

提交回复
热议问题