Yii2 When setting enablePrettyUrl, the setting method of defaultAction

WBOY
Release: 2016-08-08 09:25:04
Original
1329 people have browsed it
在使用Yii2时,如果启用了美化的Url,则访问http://www.aaa.com ,不能直接显示http://www.aaa.com/site/index.html内容。 这时候需要配置rules
Copy after login
'urlManager' => [ 
						'enablePrettyUrl' => true,
						'showScriptName' => false,
						'enableStrictParsing' => true,
						'suffix' => ".html",
						'rules' => [ '' => 'site/index', // 如果没有这里,则访问域名不能直接打开默认Action
						] 
				] 
Copy after login

Of course, if the default controller and action used are not site/index, then you need to set it here:

$config = [ 
		'id' => 'basic',
		
		//'defaultRoute'=>'site/index',
...
Copy after login

The above introduces the setting method of defaultAction in Yii2 when setting enablePrettyUrl, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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