Home > php教程 > php手册 > body text

Yii url重写自定义url显示样式

WBOY
Release: 2016-06-21 08:48:52
Original
913 people have browsed it

这里主要涉资url显示样式

 

1.打开config文件夹下面的mian.php

 

2.修改内容

 

如把地址http://www.test.com/index.php?r=site/page/sid/1修改为http://www.test.com/site/page/sid/1

 

[php]  

'urlManager'=>array(  

            'showScriptName'=>false,    // 这一步是将代码里链接的index.php隐藏掉。  

            'urlFormat'=>'path',  

            'rules'=>array(    

                '/'=>'/view',                

                '//'=>'/',  

                '/'=>'/',                  

                              

            ),  

        ),  

修改为如果想不显示参数名可直接添加规则 添加规则后地址为http://www.test.com/site/page/1

[php]  

'rules'=>array(        

                '//'=>'/',      

            ),  

还可以修改成http://www.test.com/site/page/Sid1

[php]  

'rules'=>array(        

                '//Sid'=>'/',   

            ),  

不显示controller和action http://www.test.com/Sid1

[php] 

'rules'=>array(        

                'Sid'=>'site/page',     

            ),  

 

注意定义规则的顺序

 



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!