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',

  • 相关阅读:
    练习!!标准体重
    C# 阶乘累加
    C# 阶乘
    C# 累加求和
    C# 100块钱,买2元一只的圆珠笔3块钱一个的尺子5元一个的铅笔盒每样至少一个,正好花光,有多少种花法。
    C# 一张纸0.00007m,折多少次和珠峰一样高
    C# 100以内质数
    C# 100以内质数和
    网站的基本布局
    C#递归
  • 原文地址:https://www.cnblogs.com/yanran/p/5118879.html
Copyright © 2011-2022 走看看