TP5多入口设置实例讲解
时间:2022-01-21
来源:互联网
在手机上看
手机扫描阅读
今天在用tp5做项目的时候发现,前台是可以绑定默认到index模块的,但是后台不好弄,于是查了一下手册,按照手册上说的,复制了index.php改为admin.php,作为后台的入口文件,于是域名/admin.php就可以访问后台了(默认是admin模块的index控制器的index方法),虽然可以访问了,但是我是个完美主义者,或者说室友强迫症的人,我觉得admin.php的.php看上去很是刺眼,要是能去掉就更好了,于是我就想到了把nginx的配置改一下,抱着试一试的态度,结果还是挺满意的,去掉了尾巴看上去爽多了,下面贴上代码
入口文件admin.php
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <[email protected]> // +---------------------------------------------------------------------- // [ 应用入口文件 ] // 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 绑定到admin模块 define('BIND_MODULE','admin'); // 加载框架引导文件 require __DIR__ . '/../thinkphp/start.php'; ?>
后台首页Index.php
<?php /* *功能:后台首页控制器 *作者:魏安来 *日期:2017/12/12 */ namespace app\admin\controller; class Index extends Base{ /*后台首页*/ public function index(){ return 'admin'; //return $this->fetch(); } } ?>
nginx配置vhosts.conf
server { listen 80; server_name www.tpmall.com tpmall.com; root "F:/phpStudy/WWW/tpmall/public"; location / { index index.html index.htm index.php admin.php; #autoindex on; if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=/$1 last; } if (!-e $request_filename){ rewrite ^(.*)$ /admin.php?s=/$1 last; } } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
到此这篇关于TP5多入口设置实例讲解的文章就介绍到这了,更多相关TP5多入口设置内容请搜索PHP爱好者以前的文章或继续浏览下面的相关文章希望大家以后多多支持PHP爱好者!
相关阅读 更多
-
Android SurFaceView的用法详解 时间:2025-05-01
-
Win10共享打印机709错误的原因及解决方法 时间:2025-05-01
-
什么是binkw32.dll binkw32.dll丢失的解决方法 时间:2025-05-01
-
Python中split函数详解(参数说明、作用、用法) 时间:2025-05-01
-
面向对象设计原则有哪些?每个原则是如何定义的? 时间:2025-05-01
-
C++中取整函数(ceil、floor、round)详解(定义、用法、示例) 时间:2025-05-01
今日更新
-
通过代码实例解析PHP session工作原理
阅读:18
-
PHP生成随机密码4种方法及性能对比
阅读:18
-
PHP SESSION跨页面传递失败解决方案
阅读:18
-
PHP文件操作简单介绍及函数汇总
阅读:18
-
php在linux环境中如何使用redis详解
阅读:18
-
ThinkPHP6.0如何利用自定义验证规则规范的实现登陆
阅读:18
-
如何重写Laravel异常处理类详解
阅读:18
-
PHP设计模式之命令模式示例详解
阅读:18
-
PHP变量的作用范围实例讲解
阅读:18
-
php swoft框架实例用法
阅读:18