How do I create pretty URLs? | Can You Explain It? Knowledge Bite

Опубликовано: 28 Июль 2026
на канале: SwiftOtter: eCommerce, B2B and AI
457
11

Your client on Magento 2 wants a feature that allows customers to view a list of physical stores. To fulfill this requirement, you've developed a "StoreLocator" module. You have built the store detail page, which is visible at https://{website-url}/stores/view/index/id/1. However, the requirements state that stores should have user-friendly urls, like https:{{website-url}/stores/kansas-city-ks-oak-park-mall.
❓Given the focus on best practices and maintainability, what would be the most suitable method to implement these user-friendly URLs?

ℹ️ How do I create pretty URLs?
Implement Routerinterface and add it to the RouterList array.
Examples:
vendor/magento/module-robots/etc/frontend/di.xml
Magento\Robots\Controller\Router
Create a URL generator and interpreter. Ensure that caching works as expected (don't forget IdentityInterface on the model).
---
Connect with Joseph:
LinkedIn:   / maxwelljoseph  
Twitter:   / swiftotter_joe  

https://swiftotter.com
  / swift_otter  
  / swiftotterinc  

Have you joined the free SwiftOtter Slack community? It's exploding and we don't want you to miss out. Go to https://swiftotter.com/slack to join for free and get plugged into what might be the best group of collaborating developers around!