What if I have the following route in a custom module and a path alias that is equal to the route path?

path: /contact
    _controller: Drupal\mymodule\Controller\MyController::contact
    _permission: 'access content'
  • 1
    If I recall correctly, the alias gets priority. or maybe it was the other way around. What have you found? – Jaypan Jun 21 at 8:21
  • 1
    I searched for it i didn't find any answer ! I think you are right aliases are called first – Hmad AmEdur Jun 21 at 8:32
  • 1
    I had this same issue yesterday - aliases get called first. – Janey Jun 21 at 8:43

The alias gets priority over the route.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Jdrupal Oct 7 at 7:56
  • This was the question "What if I have the following route in a custom module and a path alias that is equal to the route path?" The answer is what I said, the alias takes priority over the route. Even the comments of the OP say exactly that. I don't know how this doesn't provide an answer. – Frank Robert Anderson Oct 7 at 13:53
  • 1
    To be an answer, it lacks references. May you point out where exactly the documentation says a path alias has priority over a module route? If you understood that looking at the Drupal core code, may you show the code that is taking care of routes / path aliases resolution? – kiamlaluno Oct 16 at 12:58
  • What about if neither is the case. I cannot point to the code and there is no documentation that says it. But I have done exactly this. I have created a route and a path alias with the same value and the alias takes priority. Are you saying that because I have personal experience, and not official Drupal documentation, with this that I shouldn't answer the question? – Frank Robert Anderson Oct 17 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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