个人数据管理

仅限内部使用

TP5多入口设置实例讲解

入口文件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 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]

// 定义应用目录
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;
  }
}


发表查看: