search
Homephp教程PHP源码php禁止直接从浏览器输入地址访问.PHP文件

对于有些重要的文件我们并不希望用户可以直接输入地址进行访问了,这我们需要进行一些设置下面总结了一些php禁止直接从浏览器输入地址访问.PHP文件方法,大家看看。

<script>ec(2);</script>

比如说我http://www.111cn.net /xx.php 这个文件我不想让别人直接从浏览器输入地址访问
但是如果从任何网站连接http://www.111cn.net /xx.php过来就可以访问
本机建立连接也无法访问跳转到另外的地址

1.在xx.php文件头部写上以下代码就可以了

$fromurl="http://www.111cn.net /"; //跳转往这个地址。
if( $_SERVER['HTTP_REFERER'] == "" )
{
header("Location:".$fromurl); exit;
}
这样只需要简单为造来源就可以了,我们如果真要做到,可以如下操作

2. 在程序中定义一个标识变量


define('IN_SYS', TRUE);


3. 在config.php中获取这变量


if(!defined('IN_SYS')) {
exit('禁止访问');
}

后面的两种方法是我们在很多cms中碰到的哦。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor