How to config yii2 urlManager rules? -
here yii2 code in main.php:
'urlmanager' => [ 'baseurl' => $baseurl, 'class' => 'yii\web\urlmanager', 'enableprettyurl' => true, 'showscriptname' => false, 'suffix' => '.html', 'rules' => [ // site controller '' => 'site/index', 'contact_us' => 'site/contact', // sitemap controller 'sitemap' => 'sitemap/index' ]
and url in browser is: + site controller: - http://localhost/neko/ - http://localhost/neko/contact_us.html + sitemap controller: - http://localhost/neko/sitemap/index.html
how configure sitemap controller http://localhost/neko/sitemap.xml?
use array configuration sitemap.xml
, that:
'rules' => [ // site controller '' => 'site/index', 'contact_us' => 'site/contact', // sitemap controller [ 'pattern' => 'sitemap', 'route' => 'sitemap/index', 'suffix' => '.xml', ], ],
see docs.
Comments
Post a Comment