防止直接访问 php 文件 [英] Preventing direct access to php files

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

问题描述

这是我的文件结构示例.

Here is an example of my file structure.

/index.php
/inc
/inc/file1.php
/inc/file2.php
/inc/file3.php
/search.php

index.php 包括()file1.php、file2.php 和 file3.php.我希望它们只能通过 index.php 访问.

index.php includes() file1.php, file2.php, and file3.php. And I want them to be accessible by index.php only.

目前最优雅的解决方案是什么?

What's the most elegant solution available?

谢谢

推荐答案

将它们移到文档根目录之外:

Get them outside the document root:

/documentroot/index.php
/inc/file1.php
/inc/file2.php
/inc/file3.php

因此,无法直接访问它们.

So, there is no direct access to them whatsoever.

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

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