I want to move some permanent routes from the admin to my routes config file so that they can be version controlled.

in the admin...
news-sort/month/<year>/<month> ....
news-sort/tag/<tag> ....

Do these look ok, not 100% sure on the variable and regex etc.

'news-sort/month/(?P<year>\d{4})/(?P<month>\d{2})' => 'news-sort/index',
'news-sort/tag/(?P<tag>[a-zA-Z0-9._%-]+)' => 'news-sort/index',
'news-sort/author/(?P<author>[a-zA-Z0-9._%-]+)' => 'news-sort/index'
  • Do they work, mjr?
    – carlcs
    Commented Jul 29, 2014 at 16:07
  • I tested one and it seems to work ok
    – mjr
    Commented Jul 29, 2014 at 17:42

2 Answers 2


The simplest way to transform dynamic routes into advanced routes, is to go to your craft_routes table and copy it out of urlPattern:


If you have set this in your backend:

You'll find this in urlPattern:

Just remove the escaping \, and you've got your regex:

  • great idea, I never thought of that!
    – mjr
    Commented Jul 29, 2014 at 17:41
  • 1
    awesome answer! Commented Jul 29, 2014 at 19:48

You forgot to escape the dot, but otherwise it looks good to me.

You could replace [a-zA-Z0-9._%-] with . to allow all characters in the slug. Maybe you want to use german umlauts or other special characters in your slugs at some point (you probably shouldn't, but who knows). I'd do that (the ., not the umlauts), as I think it's not the task of a route to restrict you in doing such things.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.