Answer the question
In order to leave comments, you need to log in
How to set a rule for urlManager?
Good day! /frontend/views/site/
View files are saved in RU_ch_sitemap.xml, RU_en_sitemap.xml
, etc. What rule should be written in urlManager so that when going to mysite.com/RU_ch_sitemap.xml, the corresponding xml file opens?
Answer the question
In order to leave comments, you need to log in
If the files are not saved on the web, then you should not give direct access to them unless absolutely necessary. Make a special controller with a method that will give these files
Conditionally:
class DataController {
public function actionGetSitemap($lang) {
return file_get_contents(Yii::getAlias('@app/storage') . '/'.$lang);
}
}
'/<lang:\w+>_sitemap.xml' => 'data/get-sitemap',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question