Home > PHP Framework > YII > How to configure route beautification in yii

How to configure route beautification in yii

(*-*)浩
Release: 2019-12-30 13:46:07
Original
2704 people have browsed it

How to configure route beautification in yii

Beautify the routing form

For example: localhost/index.php?r=site/index Recommended learning: yii tutorial)

This routing form is not friendly to SEO, so can the routing be beautified? In Yii2, we can change the routing into the following form:

For example: localhost/index.php/sie/index

This routing form is the same as what we see in the browser address bar Most routing forms are the same

get. When passing parameters, you only need to pass ?

after routing.

For example: localhost/index .php/site/index?id=1

yii’s routing beautification work is solely responsible for the urlManager component.

By default, this component is not enabled. We simply configure it in the configuration file backend\config\main.php.

enablePrettyUrl: Whether to enable the beautification effect.

To achieve the simplification of the above routing, you need to configure UrlManage in the Yii2 configuration and add the following configuration in main.php:

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
],
Copy after login

The above is the detailed content of How to configure route beautification in yii. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
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