Drupal - How do you change the URL alias of a contact form?

I went under Configuration --> URL Aliases, and added a new alias for /contact-us that points to /contact/contact_us

I expected the result to be that anyone typing in /contact-us would end up at /contact/contact_us, but instead the opposite is happening. Anyone typing in /contact/contact_us is now redirected to /contact-us and the page is shown there.

This is a little different from how Drupal 7 works, but this is the answer I needed.


You can, in fact, change it. To do that you should use a route subscriber service class.

Such class will implement the alterRoutes method which will give you the ability to change the path of the contact page.

I'll update with code examples when I'll be near my computer.

Tags:

8

Path Aliases