Home > Backend Development > PHP Tutorial > Yii2 框架URL伪静态如何配置?

Yii2 框架URL伪静态如何配置?

WBOY
Release: 2016-06-06 20:27:28
Original
1319 people have browsed it

Yii2 框架如何将 www.test.com/product.html?id=5252 这样的 配置成www.test.com/product-5252.html

回复内容:

Yii2 框架如何将 www.test.com/product.html?id=5252 这样的 配置成www.test.com/product-5252.html

可以尝试在配置文件里设置类似以下这种形式

<code><?php return [
    ...
    'components' => [
        ...
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => true,
            'suffix' => '.html',
            'rules' => [
                'product-<id:>' => 'product/view',
            ],
        ],
    ],
    ...
];</id:></code>
Copy after login
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template