php框架

 首页 > php框架 > YII > YII URL 伪静态设置2

YII URL 伪静态设置2

分享到:
【字体:
导读:
          主要实现这样的url : http://localhost:84/site/contact.html 配置方法:在config/main.php中的components数组中添加 //URL管理 urlManager=array( urlFormat=path, showScriptName = false, //去除index.php urlSuffix=.html, //加...

主要实现这样的url : http://localhost:84/site/contact.html 

配置方法:在config/main.php中的‘components’数组中添加
 
//URL管理
        'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName' => false, //去除index.php
            'urlSuffix'=>'.html', //加上.html
            'rules'=>array(
                'pattern1'=>'route1',
                'pattern2'=>'route2',
                'pattern3'=>'route3',
            ),
        ),
 
然后创建.htaccess文件设置如下:
 
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
 
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
# otherwise forward it to index.php
RewriteRule . index.php
 
 
 
 
 
分享到:
YII 开启URL伪静态
1.开启apache的mod_rewrite模块      去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号      确保中有“AllowOverride All” 2.在项目中的/protected/config/main.php中添加代码: ----------------------------------------------------------------------------- 'com...
YII URL重写(开启伪静态)
目标:把这个url重写成下面那种 http://localhost/yii/index.php?r=site/login http://localhost/yii/site/login 一、确定你的apache有rewrite模块,可以通过phpinfo()来查看。 没有怎么办?自己百度 二、编辑yii的配置文件 main.php 找到 1 2 3 4 5 6 7 8 9 10 ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……