Reputation: 14142
I am having an issue using the routes in Codeigniter and my expressions
I have a URL like follows (for a offers page):
www.site.com/company/offers/view/newsarticle/219
and a route like follows:
$route['([a-z0-9_-]+)/offers/view/([a-z0-9]+)/([0-9]+)'] = "offers/view/$1/$2/$3";
I have the above route setup so if should go to the offers controller, and the view function and pass the 3 parameters (company, newsarticle, 219)
It works all fine however if the 4th uri segment contains and '-' it breaks and gives me a 404 page eg
This works
www.site.com/company/offers/view/newsarticle/219
But this doesn't
www.site.com/company/offers/view/news-article/219
Can anyone explain what I've done wrong with the expressions? Thanks
Upvotes: 0
Views: 140
Reputation: 26467
Your expression doesn't allow a hyphen character
([a-z0-9_-]+)/offers/view/([a-z0-9]+)/([0-9]+)
Should be
([a-z0-9_-]+)/offers/view/([a-z0-9\-]+)/([0-9]+)
Note the \-
in the [a-z0-9\-]
. The \
character escapes the hyphen to tell the expression engine that it's not a range operator.
Upvotes: 2