zoukankan      html  css  js  c++  java
  • TP5多入口设置

    今天在用tp5做项目的时候发现,前台是可以绑定默认到index模块的,但是后台不好弄,于是查了一下手册,按照手册上说的,复制了index.php改为admin.php,作为后台的入口文件,于是域名/admin.php就可以访问后台了(默认是admin模块的index控制器的index方法),虽然可以访问了,但是我是个完美主义者,或者说室友强迫症的人,我觉得admin.php的.php看上去很是刺眼,要是能去掉就更好了,于是我就想到了把nginx的配置改一下,抱着试一试的态度,结果还是挺满意的,去掉了尾巴看上去爽多了,下面贴上代码

    入口文件admin.php

     1 <?php
     2 // +----------------------------------------------------------------------
     3 // | ThinkPHP [ WE CAN DO IT JUST THINK ]
     4 // +----------------------------------------------------------------------
     5 // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
     6 // +----------------------------------------------------------------------
     7 // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
     8 // +----------------------------------------------------------------------
     9 // | Author: liu21st <liu21st@gmail.com>
    10 // +----------------------------------------------------------------------
    11 
    12 // [ 应用入口文件 ]
    13 
    14 // 定义应用目录
    15 define('APP_PATH', __DIR__ . '/../application/');
    16 // 绑定到admin模块
    17 define('BIND_MODULE','admin');
    18 // 加载框架引导文件
    19 require __DIR__ . '/../thinkphp/start.php';
    20 
    21 ?>

    后台首页Index.php

     1 <?php
     2 /*
     3 *功能:后台首页控制器
     4 *作者:魏安来
     5 *日期:2017/12/12
     6 */
     7 
     8 namespace appadmincontroller;
     9 
    10 class Index extends Base{
    11 
    12     /*后台首页*/
    13     public function index(){
    14         return 'admin';
    15         //return $this->fetch();
    16     }
    17 
    18 }
    19 
    20 ?>

    nginx配置vhosts.conf

     1 server {
     2         listen       80;
     3         server_name  www.tpmall.com tpmall.com;
     4         root   "F:/phpStudy/WWW/tpmall/public";
     5         location / {
     6             index  index.html index.htm index.php admin.php;
     7             #autoindex  on;
     8             
     9           if (!-e $request_filename){
    10               rewrite  ^(.*)$  /index.php?s=/$1  last;
    11           }
    12           if (!-e $request_filename){
    13               rewrite  ^(.*)$  /admin.php?s=/$1  last;
    14           }
    15 
    16         }
    17         location ~ .php(.*)$ {
    18             fastcgi_pass   127.0.0.1:9000;
    19             fastcgi_index  index.php;
    20             fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
    21             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    22             fastcgi_param  PATH_INFO  $fastcgi_path_info;
    23             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
    24             include        fastcgi_params;
    25         }
    26 }
  • 相关阅读:
    非标准的xml解析器的C++实现:二、解析器的基本构造:语法表
    非标准的xml解析器的C++实现:一、思考基本数据结构的设计
    lua5.4 beta中的to-be-closed变量的用法
    lua table与json的之间的互相转换高性能c++实现
    lua多线程共享数据的解决方案
    winsock完成端口套接字重用注意事项
    Less相关的用法以及Vue2.0 中如何使用Less
    1:MUI选择器组件抛出“n.getSelectedItem is not a function”异常的解决办法 2:mui三级联动 3:移动端关闭虚拟键盘
    redux状态管理和react-redux的结合使用
    初步学习React Router 4.0
  • 原文地址:https://www.cnblogs.com/walblog/p/8035426.html
Copyright © 2011-2022 走看看