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

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

WBOY
WBOYOriginal
2016-06-06 20:27:281316browse

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>
Statement:
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