如何指定 SEO 友好的 url,如 twitter www.twitter.com/使用YII框架

发布于 2024-08-12 06:59:53 字数 216 浏览 3 评论 0原文

我目前正在使用 Yii 框架,我想知道是否有人知道如何在 Yii 中自动设置 SEO 友好的 url,例如 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?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水波映月 2024-08-19 06:59:53

编辑配置文件 main.php 与此

'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 创建 web 应用程序时生成的

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

            ....

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

初见 2024-08-19 06:59:53

您是否无法使用 URL Manager 实现您想要的效果?如果没有,您能否发布一个示例,说明您当前拥有的以及您希望它是什么?

Are you not able to achieve what you want by using the URL Manager? If not, can you post an example of what you have currently and what you'd like it to be?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文