Hello!
Suppose that I have Post with category name and post title and I want the post URL looks like:
http://example.com/post/<post category>/<post title>/<post id>.html
This maps to post/view controller action. I’m doing the mapping with the following pattern:
post/<_category:\w+>/<_title:\w+>/<id:\d+>.html
This works good, but, the _category and _title parameters are inside of my $_GET variable.
Is there a way to map a RegExp with no parameters or a way to discard parameters?
Thanks!!
migajek
(Migajek)
2
if I get you correctly, you want to handle both "full" urls (with category and post title) as well as ones with id only?
if so, you need to add simply one more rule below the "full" one:
post/<id:\d+>.html
don’t forget it has to be below, otherwise url’s generated by Yii will look like
post/12?_category=10&_title=test
I want only get URL in the form:
http://example.com/post/games/a-beautiful-linux-game/1574862.html
This is the unique form.
The problem is that I don’t need the category name and post title and I don’t want its in my $_GET variable. Is there a way to strip those variables?
Yeah, I’m using for that a getUrl method in the Post class, thanks for advice.
Adiós!