Home > Article > CMS Tutorial > How to modify the phpcms management background path
The first step:
Create a folder in the root directory of the website. You will enter the background login interface through this folder in the future, so the folder name must be Choose a name that won’t be easily guessed. As a demonstration here, I will call it admpub. Next, create a new file index.php in this folder with the content:
<?php define('PHPCMS_PATH', realpath(dirname(__FILE__) . '/..') . '/'); include PHPCMS_PATH . '/phpcms/base.php'; // pc_base::creat_app(); $session_storage = 'session_' . pc_base :: load_config('system', 'session_storage'); pc_base :: load_sys_class($session_storage); session_start(); $_SESSION['right_enter'] = 1; unset($session_storage); header('location:../index.php?m=admin');
Step 2:
Create a new file MY_index.php in the phpcms/modules/admin/ folder , the content is:
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class MY_index extends index { public function __construct() { if (empty($_SESSION['right_enter'])) { header('location:./'); exit; } parent :: __construct(); } public function public_logout() { $_SESSION['right_enter'] = 0; parent :: public_logout(); } }
Okay, the modification is completed. In the future, you can only access the backend login portal through the admpub/ directory. If you directly use index.php?m=admin to access it, it will jump directly to the homepage of the website, thus preventing direct access to the backend login portal.
Recommended related articles and tutorials: phpcms tutorial
The above is the detailed content of How to modify the phpcms management background path. For more information, please follow other related articles on the PHP Chinese website!