zoukankan      html  css  js  c++  java
  • tp3.1

    一、url模式

        URL_MODEL
        1默认模式:pathinfo模式
        http://localhost/thinkphp3.1/index.php/Index/user/id/1.html
        0普通模式
        http://localhost/thinkphp3.1/index.php?m=Index&a=user&id=1
        2重写模式
        http://localhost/thinkphp3.1/Index/user/id/1.html
        3兼容模式
        http://localhost/thinkphp3.1/index.php?s=/Index/user/id/1.html

    <?php
    // 本类由系统自动生成,仅供测试用途
    /*
    1-输出配置文件的内容
    2-url_model模式
    */
    class IndexAction extends Action {
        public function index(){
        echo U('Index/user',array('id'=>1),'html',false,'localhost');
        }
        public function user() {
            echo 'id is'.$_GET['id'].'<br/>';
            echo '这里是index模块的user方法';
        }
    }

    二、隐藏index.php文件

      1默认模式:pathinfo模式
        http://localhost/thinkphp3.1/index.php/Index/user/id/1.html
        2重写模式
        http://localhost/thinkphp3.1/Index/user/id/1.html

    如何实现index.php的隐藏?

    1)LoadModule rewrite_module modules/mod_rewrite.so     开启

    2).htaccess

    <IfModule mod_rewrite.c>
      RewriteEngine On    //重写机制
      RewriteCond %{REQUEST_FILENAME} !-d   //重写的条件
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]    //重写的规则
    </IfModule>

    即可以使用简写使用重写式

    三、url的伪静态

    http://blog.csdn.net/shuiaaa/article/details/6561793

    伪静态,就是用户看到的地址以html.htm等静态页面的链接,实际还是动态页过,通过一些规则配置,显示在浏览器中的地址变为静态而以。

    举个简单的例子:比如你的页面为/index.php通过伪静态显示在浏览器是index.html

    class IndexAction extends Action {
        public function index(){
        echo U('Index/user',array('id'=>1),'html',false,'localhost');
        }
        public function user() {
            echo 'id is'.$_GET['id'].'<br/>';
            echo '这里是index模块的user方法';
        }
    }

    如果输入1.shtml   则显示id=‘1.shtml’;

    如果将'URL_HTML_SUFFIX'       =>  'shtml',  // URL伪静态后缀设置

    则id=1;此时输入1.html时,他又会认为id=1.html

    如何设置多个: 'URL_HTML_SUFFIX'=>'shtml|html|xml',

  • 相关阅读:
    MATLAB中mexFunction函数的接口规范
    opencv 人脸识别 (一)训练样本的处理
    VS 编程常见错误及解决方法
    在用VC编译下debug和release的什么区别
    OpenCV中Mat的详解
    主成份分析PCA
    人脸识别必读的N篇文章
    opencv有关错误及解决办法
    解决办法:CMake编译时出现“error in configuration process project files may be invalid”
    mybatis 学习笔记(二):mybatis SQL注入问题
  • 原文地址:https://www.cnblogs.com/yanran/p/5118879.html
Copyright © 2011-2022 走看看