Answer the question
In order to leave comments, you need to log in
How to properly set up a route in urlManager?
Hello! I have a module on my site where a list of articles is displayed by a separate controller. The articles themselves have this link:
static.com/page/article/post.html?slug=test-music-title , where page is the module, article is the controller, post is the view, test-music-title is the CNC(slug parameter ).
I want to shorten the link to this:
static.com/page/test-music-title.html
Also it should work with other NCs for other articles.
In the urlManager I wrote this:
'page/<slug:\w+>.html' => 'page/article/post.html?slug=<slug:\w+>'
'page/<slug:\w+>.html' => 'page/article/post.html?<slug:\w+>'
Answer the question
In order to leave comments, you need to log in
'page/<slug:\w+>.html' => 'page/article/post.html?slug=<slug:\w+>'
'page/<slug:[\w\-_\d]+>.html' => 'page/article/post'
'page/<slug:[\w\-_\d]+>.html' => '/page/article/post'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question