How to hide certain file type using apache .htaccess?

前端 未结 6 952
不知归路
不知归路 2020-12-15 07:59

Its been a long time since I\'ve needed to crack open an .htaccess file...

What is the simplest way to 40x prevent access to a specific file extension through out the

6条回答
  •  执笔经年
    2020-12-15 08:11

    I like both @Chris Lawlor's and @starkeen's answers and since OP asked about "40x" I'm going to suggest redirecting to a 404 error since it doesn't give away the fact the files exist.

    This is what I'm currently using in one of my projects:

    # Hide files not concerning the user
    RedirectMatch 404 \.(htaccess|htpasswd|ini|log|sh|inc|bak|bkp|sql)$
    

提交回复
热议问题