Good day. I use the Yii framework and now try add sitemap for my site. Since I want to create it on fly I’ve made a controller with a single method, which returns a string, without appropriate view. Here it’s code:
class SiteMapController extends Controller
{
public function accessRules()
{
return array(
array('allow','actions'=>array('index'),'users'=>array('*'),
));
}
public function actionIndex()
{
/* get a result*/
echo $res;
}
}
mysite.local/index.php/sitemap works just fine, but when I write in main.php:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'admin/<action:\w+>' => 'admin/<action>',
'sitemap.xml' =>'sitemap/index',
),
I get 404 error trying to access mysite.local/sitemap.xml.
I’ve read url manager reference, but still cannot figure out what I’m doing wrong.
Thanks.