Hello All,
Please help me to add hyphen to url.
Here is my pre configured url manager:
...
'urlManager' => array(
'brands/<name:\w+>' => 'brands/view',
),
...
By configuring I’m able to visit url:
http://mysite.com/brands/abc
But not:
http://mysite.com/brands/abc-xyz
Please help me to add hyphen to use above url
Thanks
abennouna
(Abennouna)
August 8, 2012, 3:41pm
2
[font="Courier New"]\w[/font] means an alphanumeric character, and [font="Courier New"]\w+[/font] means one or more of them. But a hyphen is not an alphanumeric character. So my approach is:
'brands/<name:.+>' => 'brands/view',
rootbear
(Alex Xm)
August 8, 2012, 5:01pm
3
this even works for name with space ‘brands/something like this’
'brands/<name:.+>' => 'brands/view',
if you want limit to alphanumeric plus ‘-’ or ‘_’, you can do this
'brands/<name:[a-z|0-9|\-|\_]+>' => 'brands/view',
rootbear:
this even works for name with space ‘brands/something like this’
'brands/<name:.+>' => 'brands/view',
if you want limit to alphanumeric plus ‘-’ or ‘_’, you can do this
'brands/<name:[a-z|0-9|\-|\_]+>' => 'brands/view',
Thanks Root Bear,
This I was looking
'brands/<name:[a-zA-Z\-]>' => 'brands/view',
Will this work naa?