Home  >  Article  >  Backend Development  >  Yii2 When setting enablePrettyUrl, the setting method of defaultAction

Yii2 When setting enablePrettyUrl, the setting method of defaultAction

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

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',
...

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.

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
Previous article:Smarty-1 (18)Next article:Smarty-1 (18)