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:
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?
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:
don’t forget it has to be below, otherwise url’s generated by Yii will look like
I want only get URL in the form:
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.