• 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模式可以访问了,地址重写成功。

  • 相关阅读:
    JVM视角:值传递or引用传递?【转】
    mybaits trim用法
    Collections.shuffle()用法
    api缓存
    接口开发
    Integer.parseInt()和这个Integer.valueOf()的详解【转】
    MyBatis 通过包含的jdbcType类型
    idea 相关设置
    idea快捷键
    equals 与 ==
  • 原文地址:https://www.cnblogs.com/agile2011/p/4733680.html
Copyright © 2020-2023  润新知