1.配置Hosts文件
C:\Windows\System32\drivers\etc\hosts
2.D:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
查找Include conf/extra/httpd-vhosts.conf,去掉前面的#号
3.配置Apache文件
D:\wamp\bin\apache\Apache2.2.17\conf\extra
- <!-- 配置信息 -->
- <VirtualHost *:80>
- ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev
- DocumentRoot "d:/wamp/www/think5/public"
- ServerName www.kmgfyy120.com
- ErrorLog "logs/dummy-host2.hleclerc-PC.ingenidev-error.log"
- CustomLog "logs/dummy-host2.hleclerc-PC.ingenidev-access.log" common
- </VirtualHost>
去除index.php路径
1、如果没有开启 URL_REWRITE,则你需要找到 Apache 中的 httpd.conf 这个配置文件,找到下面这行:
#LoadModule rewrite_module modules/mod_rewrite.so
把前面的警号去掉,然后继续找到下面这句:
2、AllowOverride None
将所有找到的以上语句都改为:AllowOverride All
以上修改完毕然后重启 Apache 服务器即可。
3、在应用的根目录下面新建一个 .htaccess 文件。在文件里面加入如下代码:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
第一步:public目录下 build.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>
- // +----------------------------------------------------------------------
- return [
- // 生成应用公共文件
- \'__file__\' => [\'common.php\', \'config.php\', \'database.php\'],
- // 定义demo模块的自动生成 (按照实际定义的文件名生成)
- \'admin\' => [
- \'__file__\' => [\'common.php\'],
- \'__dir__\' => [\'behavior\', \'controller\', \'model\', \'view\'],
- \'controller\' => [\'Index\', \'User\',\'Config\'],
- \'model\' => [\'Models\', \'ModelsField\',\'Config\'],
- \'view\' => [\'index/index\',\'config/index\'],
- ],
- // 其他更多的模块定义
- ];
index.pxp修改为:
- <?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\';
- //读取自动生成定义文件
- $build = include \'build.php\';
- //运行自动生成
- \think\Build::run($build);
4.在网页上面搜索域名即可