Table of Contents
php prohibits accessing .php files by directly entering the address from the browser,
Home Backend Development PHP Tutorial How to prevent php from directly entering the address from the browser to access .php files, _PHP Tutorial

How to prevent php from directly entering the address from the browser to access .php files, _PHP Tutorial

Jul 13, 2016 am 10:15 AM
php file prohibit access

php prohibits accessing .php files by directly entering the address from the browser,

The example in this article describes how PHP prohibits accessing .php files by directly entering the address from the browser. Share it with everyone for your reference. The specific implementation method is as follows:

Generally speaking, we do not want users to directly enter the address to access some important files, so we need to make some settings for this. The following summarizes some PHP methods to prohibit accessing .PHP files directly from entering the address in the browser, which are very practical.

For example, I don’t want others to access the file http://www.bkjia.com/xx.php by entering the address directly from the browser.

But if you cannot access http://www.bkjia.com/xx.php from any website, you will not be able to access it even if you establish a connection locally and jump to another address.

1. Just write the following code in the header of the xx.php file

Copy code The code is as follows:
$fromurl="http://www.bkjia.com/"; //Jump to this address.
if( $_SERVER['HTTP_REFERER'] == "" )
{
header("Location:".$fromurl); exit;
}

In this way, we only need to simply forge the source. For this, we can also do the following:
2. Define an identification variable in the program

Copy code The code is as follows:
define('IN_SYS', TRUE);

3. Get this variable in config.php

Copy code The code is as follows:
if(!defined('IN_SYS')) {
exit('Access prohibited');
}

The latter two methods are what we encounter in many cms.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/906119.htmlTechArticlephp prohibits accessing .php files directly from entering the address in the browser. The example of this article describes how to prohibit php from directly entering the address from the browser. How to access the .php file by inputting the address. Share it with everyone for your reference...
Statement of this Website
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up WeChat to prevent others from adding me to group chats. How to set up WeChat to prevent others from adding me to group chats. How to set up WeChat to prevent others from adding me to group chats. How to set up WeChat to prevent others from adding me to group chats. Mar 13, 2024 am 08:37 AM

The chat method provided in the WeChat app is very simple. You can chat anytime and anywhere. All chats are free of charge, creating a comfortable and relaxed social atmosphere. You can interact and chat wherever you go, so you won't feel bored all day long. Download a lot of interesting emoticons and kaomojis for free. Enter your mobile phone number to log in online and interact and chat with friends and family online. No matter how far away you are, you can contact each other immediately and open a dialog box to communicate easily. Of course, sometimes you You may also enter a group chat you don’t know for no reason. Of course, you are not interested in this group. You can also set it up to prevent others from dragging you in. The chat will be much better. Now the editor is online to provide detailed settings for WeChat users one by one. How to prevent others from dragging me into group chats. 1The first step

How to open php files on mobile phone How to open php files on mobile phone Nov 13, 2023 am 11:08 AM

To open a php file on a mobile phone, you need to set up a server environment that can run php on the mobile phone and upload the php file to the server. Then, enter the IP address or domain name of the server, plus the path to the php file, into the browser on your phone to open the php file and view its contents.

How to access JSONNode's JSON fields, arrays and nested objects in Java? How to access JSONNode's JSON fields, arrays and nested objects in Java? Aug 30, 2023 pm 11:05 PM

A JsonNode is Jackson's JSON tree model that can read JSON into JsonNode instances and write JsonNode into JSON. We can use Jackson to read JSON into a JsonNode by creating an ObjectMapper instance and calling the readValue() method. We can access fields, arrays or nested objects using the get() method of the JsonNode class. We can use the asText() method to return a valid string representation and convert the node's value to Javaint using the asInt() method of the JsonNode class. In the example below we can access Json

iOS 17: How to control which apps can access your photos iOS 17: How to control which apps can access your photos Sep 13, 2023 pm 09:09 PM

In iOS17, Apple has more control over what apps can see in photos. Read on to learn how to manage app access by app. In iOS, Apple's in-app photo picker lets you share specific photos with the app, while the rest of your photo library remains private. Apps must request access to your entire photo library, and you can choose to grant the following access to apps: Restricted Access – Apps can only see images that you can select, which you can do at any time in the app or by going to Settings &gt ;Privacy & Security>Photos to view selected images. Full access – App can view photos

How to Fix Reddit is Banned Funny Error in Reddit How to Fix Reddit is Banned Funny Error in Reddit Oct 26, 2023 pm 11:21 PM

What is "RedditisFunErrorForbidden"? Reddit is an interesting application with error-free messages that are commonly found on websites and social forums. This error pops up when a user tries to access certain areas or perform specific actions on the platform without the required permissions. The platform is a large online forum with many smaller forums and different ways for users to interact. It has certain rules and restrictions to keep things safe and orderly. What is the reason for "Reddit is banned for funny bug"? Understanding the problem will help users identify common causes. Here are some common causes of errors. Private subreddits: If the subreddit you are trying to access is set to private, you will need to

How to limit modification time in win10 home version How to limit modification time in win10 home version Jan 08, 2024 pm 08:34 PM

Under certain circumstances, strictly restricting users from making any adjustments to time can ensure that the various data generated during the entire system operation remain accurate and inherently stable and consistent. However, although many users are not clear on how to implement this time limit on Windows 10 Home Edition computers, you can still refer to the following detailed steps to implement this specification requirement. Win10 Home Edition prohibits time modification. Method 1. Press win+ RThen select "Run" 2. Enter "secpol.msc" 3. Click "Local Policy" - "User Rights Assignment" 4. Double-click on the right to open "Change System Time" 5. Select the user name, click Delete, click Apply and Confirm to complete the setting

Access metadata of various audio and video files using Python Access metadata of various audio and video files using Python Sep 05, 2023 am 11:41 AM

We can access the metadata of audio files using Mutagen and the eyeD3 module in Python. For video metadata we can use movies and the OpenCV library in Python. Metadata is data that provides information about other data, such as audio and video data. Metadata for audio and video files includes file format, file resolution, file size, duration, bitrate, etc. By accessing this metadata, we can manage media more efficiently and analyze the metadata to obtain some useful information. In this article, we will take a look at some of the libraries or modules provided by Python for accessing metadata of audio and video files. Access audio metadata Some libraries for accessing audio file metadata are - using mutagenesis

How to solve the problem of inaccessibility after Tomcat deploys war package How to solve the problem of inaccessibility after Tomcat deploys war package Jan 13, 2024 pm 12:07 PM

How to solve the problem that Tomcat cannot successfully access the war package after deploying it requires specific code examples. As a widely used Java Web server, Tomcat allows developers to package their own developed Web applications into war files for deployment. However, sometimes we may encounter the problem of being unable to successfully access the war package after deploying it. This may be caused by incorrect configuration or other reasons. In this article, we'll provide some concrete code examples that address this dilemma. 1. Check Tomcat service

See all articles