您的位置 首页 技术

yii中如何重新url

一、Url重新规则 1、将项目的地址修改成静态模式(伪静态===Url路由管理): a)Index.html === index.php?r=index/index b)Cate-…

一、Url重新规则

1、将项目的地址修改成静态模式(伪静态===Url路由管理):       a)Index.html  ===  index.php?r=index/index       b)Cate-1.html  ===  index.php?r=article/list&cid=1       c)Art-1.html   ===  index.php?r=article/index&aid=1d)想完成上述功能:     i.需要有apache功能模块的支持 url重写模块     ii.修改apache配置文件,apache安装目录/Conf/httpd.conf           1.LoadModule rewrite_module modules/mod_rewrite.so           2.AllowOverride All     iii.重启apache,使其修改生效e)使用yii框架的URL路由功能:i.隐藏入口文件1.编辑.htaccess文件   a)RewriteEngine On   b)RewriteCond %{REQUEST_FILENAME} !-f   c)RewriteCond %{REQUEST_FILENAME} !-d   d)RewriteRule . index.php2.编辑项目配置文件bbs/protected/config/main.php   a)'urlManager'=>array(i.'urlFormat'=>'path',//开启pathinfo格式ii.'showScriptName'=>false,//index.php 隐藏入口文件iii.‘urlSuffix’=>’.html’,iv.'rules'=>array(    1.‘index’=>’index/index’,    2.‘cate-<cid:\d+>’=>’article/list’,    3.‘art-<aid:\d+>’=>’article/index’,v.),b)),

二、Yii框架的$this->createUrl方法

Yii框架的$this->createUrl方法会自动根据url规则产生对应的超链接,因此,在项目开发过程当中,所有的超链接我们都需要使用createUrl帮助我们产生。

相关文章教程推荐:yii框架

以上就是yii中如何重新url的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/20381.html

为您推荐

返回顶部