Book Image

Magento 2 Development Cookbook

Book Image

Magento 2 Development Cookbook

Overview of this book

With the challenges of growing an online business, Magento 2 is an open source e-commerce platform with innumerable functionalities that gives you the freedom to make on-the-fly decisions. It allows you to customize multiple levels of security permissions and enhance the look and feel of your website, and thus gives you a personalized experience in promoting your business.
Table of Contents (18 chapters)
Magento 2 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Changing the URL of a product page


When you are on a product page, the URL of every product always looks clean. The name in the URL makes it very SEO friendly.

In this recipe, we will explore the possibilities of URL rewrites in Magento.

Getting ready

In the backend, navigate to Products | Inventory | Catalog and look for a simple product with visibility Catalog, Search. This recipe is based on the Endeavor Daytrip Backpack product from the sample data.

How to do it

In the following steps, we will see the procedure for changing a URL of a product detail page.

  1. Find the appropriate product in the frontend. You can find by navigating to Gear | Bags. If you open the product detail page, you will see the URL /endeavor-daytrip-backpack.html.

  2. In the backend, change the URL key attribute to buy-now-endeavor-daytrip-backpack.

  3. Reload the product in the frontend. The URL will change to the one we have just entered in the backend.

    Tip

    When you select the Create Permanent Redirect option for an old URL checkbox...