Allows SEO URLs for categories without a trailing slash.
Without this extension, category URLs that do not end with a trailing slash would lead to a 404 Not Found error page. With this extension, those URLs will lead to the expected category page. The extension respects Shopware's SEO forwarding behavior setting, either a 301 redirect or a rel="canonical" HTTP header.
The problem is described in this issue: shopware/shopware#468
There is also a forum discussions about it (german): https://forum.shopware.com/t/seiten-nur-mit-am-ende-der-url-aufrufbar/65242
Important
Always test new plugin versions in a dev environment before using it in a production/live shop.
- Download the ZIP archive from the latest release.
- Copy the ZIP archive into the
custom/plugins
directory of your Shopware 6 installation. - Unzip the ZIP archive.
- There should now be a folder named
BaristaNoTrailingSlashSeoUrl
in thecustom/plugins
directory of your Shopware 6 installation. - Log in to the Admin UI of your shop and go to
Extensions > MyExtensions
. - Find the
SEO category URLs without trailing slash
extension (Deutsch:SEO Kategorie URLs ohne abschließenden Schrägstrich
) in the list. - Install and activate it.
The Shopware\Core\Content\Seo\SeoResolver
class resolves SEO URLs to native Shopware URLs.
SeoResolver
is called by Shopware\Storefront\Framework\Routing\RequestTransformer
for each request.
SeoResolver
searches in the seo_url for an entry that matches the actual path (seo_path_info
).
That entry will contain the shopware native path (path_info
).
RequestTransformer
then replaces the actual path of the request URL with the value of path_info
.
If SeoResolver
does not find a matching entry, it just returns the actual path for path_info
.
Luckily, SeoResolver
is not called directly by RequestTransformer
.
Instead, an instance of AbstractSeoResolver
, which SeoResolver
extends, is injected as a service into RequestTransformer
.
That means we can use Symfonys service decoration pattern to adjust the behavior of SeoResolver
to our needs.
See this chapter in the Shopware 6 documentation for an explanation of how that is done.