Matching Two Similar Url's, Routing To Different Controller Functions

I am having some issues with the URL’s, they are currently like this and working fine:

[color="#FF0000"]/blog/my-blog-post-example[/color] with the URL manager set to [color="#FF0000"]‘blog/<slug:[\w\-]+>’ => ‘blog/view’,[/color]

However I need another work around so if the URL contains %20 instead of a - it goes to a different controller function which will 301 redirect to the correct URL. Is it possible to have the two entries in URLmanager to do this:

‘blog/<slug:[\w\-]+>’ => ‘blog/view’, - works perfect

‘blog/WORK-AROUND’ => ‘blog/badurl’,

Thanks in advance.

I think a quick solution would be to match only non-space characters:


'blog/<slug:[a-zA-Z0-9-]+>' => 'blog/view',

Thanks Bennouna, it did not solve my problem but I solved it :)

Glad you solved it! But could you share your solution in case someone else meets the same issue? Thanks in advance ;)