如何从php文件中禁止URL? [英] How to make URL forbidden from php file?

查看:57
本文介绍了如何从php文件中禁止URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有让URL禁止从php文件访问而没有触摸(配置)webserver ??

Is there anyway to make URL forbidden to access from php file without "touching" (configure) the webserver??

推荐答案

如果你使用的是Apache Webserver,您可以创建 .htaccess 文件并在其中添加此代码:

If you use an Apache Webserver, you can create a .htaccess file and add this code inside it:
<Files forbiddenfile.php>
Order Deny,Allow
Deny from All
</Files>

ErrorDocument 403 /ErrorPages/403.php



如果您发现这是配置服务器,您还可以将用户重定向到403页面访问 forbiddenfile.php


If you find that this is configuring the server, you can also redirect the user to the 403 page if he tries to access forbiddenfile.php:

<?php
header('Location: /ErrorPages/403.php'); // add this PHP code at the top of your PHP file
?>  



希望这会有所帮助。


Hope this helps.


这篇关于如何从php文件中禁止URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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