Prevent others from downloading or accessing your PHP configuration files

Methods to prevent direct access, viewing or downloading of the config.php file

Prevent others from downloading or accessing your PHP configuration files?
If your config file is config.php with username and password to access the database, you definitely don't want people to see or download it

Here is a solution, which is also a commonly used method in many php programs for your reference.

1. First define the identification variable

code show as below:
define('IN_SYS', TRUE);

2. Get this variable in config.php

code show as below:
if (!defined('IN_SYS')) {
  exit('Access prohibited');

This enables undefined arbitrary viewing or downloading.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112114&siteId=291194637