使用Apache .htaccess限制直接文件访问 [英] Restrict direct file access with Apache .htaccess

查看:297
本文介绍了使用Apache .htaccess限制直接文件访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制对具有.inc的每个文件的直接访问.在文件名中?基本上,我这样做是为了指出必须仅包含特定文件.已经将Apache和mod_rewrite用于基本的SEO用途,这超出了我的理解. .htaccess应该可以以某种方式立即解决问题,

How can I restrict direct access to every file that has .inc. in the file name? Basically I did that to point out that the specific file must only be included. Already using Apache and mod_rewrite for basic SEO purposes, by this goes a "bit" beyond my knowledge. .htaccess should somehow do the trick straight away, hopefully.

推荐答案

尝试一下:

RewriteCond %{REQUEST_URI} \.inc\. [NC]
RewriteRule . - [F]

或者这也可行

RewriteRule \.inc\. - [F]

这将授予拒绝权限.

或者您也可以使用找不到的404页面:

Or you can also use a 404 page not found:

RewriteRule \.inc\. /404.php [L,NC] #or your own 404 page file

这篇关于使用Apache .htaccess限制直接文件访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆