阻止特定的文件扩展名与htaccess的? [英] Blocking specific file extension with htaccess?

查看:159
本文介绍了阻止特定的文件扩展名与htaccess的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这code发送所有的请求到一个php文件:

I am using this code to send all the request to a single php file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) myfile.php?id=$1 [QSA,L]

但现在我也想阻止的直接进入以myfile.php等PHPS。我不希望PHP文件,直接通过浏览器打开,但他们必须合作,包括与这样的。

But now I want to also block direct access to myfile.php and other phps. I don't want the php files to open directly via browser, but they must work for includes and such.

我怎样才能做到这一点?

How can I do this?

推荐答案

也许这将有所帮助:

RewriteCond %{REQUEST_URI} !(.*).php$ [NC]
RewriteRule ^.* - [F,L]

有几个很好的例子在这里: Apache的维基:的RewriteCond

Several nice examples are here: Apache wiki: RewriteCond

这篇关于阻止特定的文件扩展名与htaccess的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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