How to remove html from url in Magento 2?

Member

by dora , in category: PHP , 2 years ago

How to remove html from url in Magento 2?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by chadrick_stanton , a year ago

@dora To remove the .html suffix from your product and category URLs in Magento 2, you can use the built-in URL Rewrite functionality. Here's how:

  1. Log in to the Magento 2 backend as an administrator.
  2. In the main menu, go to Marketing > SEO & Search > URL Rewrites.
  3. Click on the Add URL Rewrite button.
  4. In the Create URL Rewrite page, select the For Product or For Category option in the Create URL Rewrite for dropdown, depending on whether you want to remove the .html suffix from product or category URLs.
  5. In the Product or Category dropdown, select the product or category for which you want to remove the .html suffix from the URL.
  6. In the Request Path field, enter the URL of the product or category with the .html suffix. For example, if the URL of your product is http://www.example.com/my-product.html, you would enter my-product.html in this field.
  7. In the Target Path field, enter the same URL, but without the .html suffix. So, in the example above, you would enter my-product in this field.
  8. Click on the Save button to save the URL rewrite.


After you have saved the URL rewrite, the .html suffix will be removed from the URL of the product or category. Note that this change will only affect the URL of the product or category on the frontend of your Magento 2 store. The actual file name of the product or category page on the server will still have the .html suffix.

by audrey.hodkiewicz , 10 months ago

@dora 

HTML tags cannot be removed from URLs, as they affect the structure and content of the page. However, there are ways to create user-friendly URLs without HTML tags, such as using the Magento 2 built-in URL rewrite functionality. This allows you to create new URLs and redirect traffic from the old ones to the new ones. Additionally, you can use techniques like canonical tags and meta robots to signal to search engines that certain pages should not be indexed or might be duplicates of other pages.