How to hide admin.php in tp5
tp5隐藏admin.php的方法:1、定义入口文件admx.php,并在入口文件绑定admin模块;2、在config/app.php文件中,配置禁止访问admin;3、配置nginx伪静态即可。
本文操作环境:windows7系统、thinkphp v5.1版、DELL G3电脑
tp5怎么隐藏admin.php?
tp5 隐藏后台
为了后台的安全,一般后端开发人员都会对后台路径进行隐藏。
踩了多天的坑,终于想到了,tp5.1隐藏后台目录的方法了。
假设我的后台目录为 "/admin"
1.定义入口文件admx.php(也可以是很难猜的文件名),并在入口文件绑定admin模块
<?php // [ 应用入口文件 ] namespace think; define('CONFIG_PATH',__DIR__.'/../config/'); // 加载基础文件 require __DIR__ . '/../thinkphp/base.php'; // 执行应用并响应 Container::get('app')->bind('admin')->run()->send();
2.然后在config/app.php文件中,配置禁止访问admin
// 禁止访问模块 'deny_module_list' => ['common','admin'],
测试: 通过域名+/admin 的方式已经无法访问,只能通过域名+admx.php的方式去访问,仔细观察URL你会发现,实际上admx.php == /admin。
目前这种方式是对代码改动最小的。
3,nginx 伪静态的配置
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } location /admx.php/ { if (!-e $request_filename) { rewrite ^/admx.php/(.*)$ /admx.php?s=$1 last; break; } }
推荐学习:《PHP视频教程》
The above is the detailed content of How to hide admin.php in tp5. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









