赞
踩
打开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/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';

实现功能
index.php 这个入口文件,只能去前台模块
admin.php这个入口文件,只能去后台模块(建议后台入口文件复杂一些)
如何实现
在入口文件中
// 定义前台
define('BIND_MODULE', 'index');
// 绑定后台
define('BIND_MODULE', 'admin');
URL地址发生变化
入口绑定之前(http://www.tp.com/admin.php/模块/控制器/方法)
入口绑定之后(http://www.tp.com/admin.php/控制器/方法)
开启apache重写(D:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf)
把注释开启 LoadModule rewrite_module modules/mod_rewrite.so
设置访问权限(D:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf)
<VirtualHost *:80>
ServerName www.tp.com
DocumentRoot D:/wamp64/www/study/thinkphpstudy/public
<Directory "D:/wamp64/www/study/thinkphpstudy/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
入口文件,在网站public目录下新建.htaccess文件,
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
重启服务
关闭后台模块,在后台入口文件中(admin.php),写在加载框架引导文件之后,否则报错。
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +------
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。