thinkphp加载 和url_model

1.加载thinkphp.php

requrie('./ThinkPHP/ThinkPHP.php');

2.加载核心文件 ./thinkPHP/LIB/core

3.加载项目的文件 分析URL 调用相关控制器

m module 模块 控制器

a action 方法 action=页面

muke.com/index.php?m=index&a=index

自定义配置文件

在启动项加入 define('APP_DEBUG',true);

可在Conf目录下添加任意配置文件如user.php.

<?php
return array(
       'username'=>'username2',
        );

?>

添加完成后在 config.php文件中加入扩展配置文件项:

 'LOAD_EXT_CONFIG'=>'user',

自定义配置文件每次都会被加载,应该不推荐使用。

URL_MODEL

在config.php里添加配置

'URL_MODEL'=>3,

1.默认模式 pathinfo 模式1 http://muke.com/index.php/Index/user/id/1.html

0普通模式 最传统的普通模式  http://muke.com/index.php?m=Index&a=user&id=1

2重写模式 http://muke.com/Index/user/id/1.html

3兼容模式 http://muke.com/index.php?s=/Index/user/id/1.html

echo C('URL_MODEL');  //获取URL_Model配置

 echo U('Index/user',array('id'=>1),'html',FALSE,'muke.com');

关于url_model方式为2时 重写模式,隐藏掉index.php如何实现:

1.先修改httpd.conf 查找 rewrite.so 把该行前面的#号去掉,保存之后 重启服务

2.在项目根目录与index.php一个目录的位置新增文件名为.htaccess,内容增加如下:

<Ifmodule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

</Ifmodule>

ok.url_model 2模式可以访问了,地址重写成功。

原文地址:https://www.cnblogs.com/agile2011/p/4733680.html