Cannot save contact as the URL key

This article provides a workaround for the issue when you are not able to save contact as a URL key (e.g., “/contact”) for products or CMS pages.

Affected products and versions

Adobe Commerce (all deployment methods) 2.4.x

Issue

You cannot save a product or a CMS page using the term contact as the URL key. When you try to save the URL key, you receive an error that indicates that the URL key is a duplicate URL.

Steps to reproduce:

Create a CMS page with contact as the URL key.

Expected result:

The page is saved with contact as the URL key.

Actual result:

You cannot save the page. You get the error: The value specified in the URL Key field would generate a URL that already exists.

Cause

Contact is a reserved word defined in vendor/magento/module-contact/view/frontend/layout/contact_index_index.xml.


<router id="standard">
      <route id="contact" frontName="contact">
          <module name="Magento_Contact" />
      </route>
  </router>

Solution

You cannot use the term contact as your URL key, however, you can use the term contact combined with another letter or number (for example, contact1 and contact2). Although the term does not have to be contact+<another number or letter>, the term could be any string as long as the length does not exceed 255 characters.

Perform the following steps:

  1. Log in to Commerce Admin.

  2. Go to Marketing > SEO & Search > URL Rewrites.

  3. Click Add URL Rewrite.

  4. Select Custom on the Create URL Rewrite drop-down.

    1. In the Request Path, type “contact”. Note that the Request Path is what a user enters in the browser and the Target Path is where it should redirect to.
    2. In the Target Path, type in the new URL key (for example, “contact1”).
    3. Select No in the Redirect drop-down.
recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a