主配置文件,main.php的组件(components)中开启路由模式
1 2 3 4 5 6 7 8 9 10
| 'urlManager' => [ 'urlFormat' => 'path', 'showScriptName' => false, 'urlSuffix' => '.html', 'rules' => [ '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ], ],
|
去掉路径中index.php名称
在网站根目录下新键一个.htaccess文件
里面内容:
1 2 3 4 5 6 7 8 9 10 11
| * show index.php? * Options +FollowSymLinks IndexIgnore *\/* RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
|