I change to change default contact url from /contact/ to /customcontact/ or something. How we do that in magento2?


The easiest way is to use Magento's URL rewrite feature from your store admin section.

Here are the steps to do so:

  1. In the admin menu go to Marketing -> URL Rewrites.
  2. Click the Add URL rewrite button.
  3. Select the "Custom" URL rewrite type
  4. Select the store for which you want to create the custom url (which will replace "contact")
  5. In the requested path field type your new custom contact url (e.g. contact-us)
  6. In the target path field type the current contact url (contact)
  7. Clear the cache and you're done (maybe also wait for cron to reindex the urls)

The same can be done for any other in-built Magento url (like /checkout or /cart).

This is a multi-store and multi-language friendly solution.

| improve this answer | |
  • Not working for me. contact.html is giving 404 error. Any solution for this issue? Thank you. – Ronak Parmar Jan 21 '19 at 6:40
  • Not sure... the only alternative is to edit /vendor/magento/module-contact/etc/frontend/routes.xml and change only the frontName attribute from contact to whatever you want the url to be. But know that by doing this, you are overriding a core module and when you upgrade Magento, you will lose this change. – Lez Jan 21 '19 at 8:13
  • Thanks for the reply, but this is not the correct solution for this, but I have found alternative way to do it, I have created a page and called contact us block in that page, and SEO url of that page is "contact.html" and my issue is fixed now. This is the correct alternative to it with changing any core file. Thanks again. – Ronak Parmar Jan 21 '19 at 8:50

I got a similar question and answer here Magento 2 - rewrite checkout and account url

Just change modify and change it to Contact form module.

| improve this answer | |

If you have applied above solution but if "contact.html" page will give you 404 error, then you can use alternative way to change "contact" url to "contact.html". I have the same issue, so I have created a Page called "Contact" with "contact.html" url, and I have called contact form block in that page and it is working fine for me.

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}

You have to add above code in Page, and Magento Contact form will work fine. Thank you.

| improve this answer | |

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.