如何指定SEO友好的网址,例如twitter www.twitter.com/<name>使用YII框架 [英] How to specify a SEO friendly url like twitter www.twitter.com/<name> using YII framework

查看:76
本文介绍了如何指定SEO友好的网址,例如twitter www.twitter.com/<name>使用YII框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用Yii框架,我想知道是否有人对如何在Yii中自动设置SEO友好的网址(如www.twitter.com/)有所了解?我知道如何在config/main.php中手动执行此操作,但我希望能够动态生成它.我也已经能够在Grails中做到这一点.在Yii中,我所知道的是您需要具有另一个参数,例如www.twitter.com/l/,但是我不希望该参数,任何人都可以共享?

I am currently using the Yii framework, and I would like to know if anyone has any clue on how to setup a SEO friendly url like www.twitter.com/ automatically in Yii? I know how to do so this manually in the config/main.php but I would like to be able to dynamically generate it. I have been able to do it in Grails as well. In Yii, what I know of is that you need to have another parameter like www.twitter.com/l/, but I do not want that parameter, anyone can share?

谢谢.

推荐答案

以此编辑配置文件main.php

Edit the config file main.php with this

'components'=>array(

            .....

            'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),

            ....

我认为它是在您使用yiic-tool创建网络应用程序时生成的

I think it is generated when you create a webapp with yiic-tool

这篇关于如何指定SEO友好的网址,例如twitter www.twitter.com/&lt;name&gt;使用YII框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆