Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't suspect it's currently possible but I would be pleasantly surprised to find that it is.

I'm going to use an example from Django because I've seen it used there and a similar implementation would be handy to have in Craft. Annnnd it would be helpful for what we're trying to achieve with my current project.

Example: In Django you have your project-wide (think of this as routes.php in Craft). Additionally you can have app-specific URLs (an App might be a Blog or a Portfolio). You can define the app-specific paths in the app-specific file and then you can include those URLs in the project-wide URL file. That might look like this (example from the Django docs):

urlpatterns = [
    # ... snip ...
    url(r'^community/', include('django_website.aggregator.urls')),
    url(r'^contact/', include('')),
    # ... snip ...

So a use-case:

We're developing a REST API and right now all of our routes are defined in routes.php. That's an ok solution, but we have a lot of plugin-specific routes. It would be nice to be able to define a base such as /api/ and pass the rest of the request to a plugin-specific routes file.

An idea of what this might look like:

return array(
    'api'   => array('pluginRoutes' => 'apiPluginName'),

And then in craft/plugins/apiPluginName/routes.php would be a routes file similar to the project-wide routes.php file in craft/config

share|improve this question
up vote 8 down vote accepted

Is the registerSiteRoutes hook what you're looking for?

share|improve this answer
I think this is exactly what I want :) – Tyler Willingham Jul 24 '14 at 15:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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