Routing

Resolving requests to Enact entails a few steps, below are the steps in order of precedence:

  1. Control panel requests – If the request uri is a request to a default enact resource or page it will be served. You define where enact lives publicly (the access uri) with the general configuration setting cpAccessSlug which defaults to /admin/.

  2. Private plugin routes – Any plugins you have installed which define the method privateRoutes will have it executed and subsequently have any matching routes executed.

  3. Redirect - If the request uri has an active redirect rule set the redirect will be performed and the request will exit.

  4. Entry – If the request uri matches with an entry in the database the entry's section template will be injected with the loaded entry variable.

  5. Route – If the request uri matches a custom created route via the route control panel then the action defined by the route will be executed:

    • A template – If the routes action was to execute a template, then any of the tokens defined by the route will be injected into the defined template.

    • A controller – If the routes action was to execute a controller, then the controllers method will be called and passed the defined tokens in the order they are defined to the method of the controller.

  6. Template – For a request uri to match a template directly it can't begin with the private template prefix, defined by the general configuration setting privateTemplatePrefix, so by default _about-us.html will not match /about-us because it is using the _ prefix. Also by default the setting allowURITrailingSlashes is set to true which allows for request uri's like /about-us/ to match the template about-us.html.

  7. Public plugin routes – Any plugins you have installed which define the method publicRoutes will have it executed and subsequently have any matching routes executed.