【发布时间】:2012-11-16 08:41:58
【问题描述】:
我的目录中有近 30 个 php 文件,4 个子目录。我想阻止用户直接查看一些 php 文件和子目录,例如 http://bhavani.com/hai.php
我当前的htaccess文件
## Enable Mod Rewrite, this is only required once in each .htaccess file
RewriteEngine On
RewriteBase /
## Test for access to includes directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /includes/ .*$ [NC]
## Test that file requested has php extension
RewriteCond %{REQUEST_FILENAME} ^.+\.php$
## Forbid Access
RewriteRule .* - [F,NS,L]
怎么做?
【问题讨论】:
-
您可以在 php 文件的开头创建一个简单的 if() 语句,例如用户登录或访问它们所需的任何内容,如果没有,则 header("404");退出;