DfRedirects — 301 redirects and 404 capture for Shopware 6
301/302/410 redirects and 404 log for Shopware 6: installation, rules, suggestions, CSV import and troubleshooting.
Overview
DfRedirects adds a real redirect manager to Shopware 6: 301, 302, 307, 308 and 410 rules with exact, wildcard or regular-expression matching, automatic capture of the 404 errors your visitors hit, target suggestions based on URL similarity, and bulk CSV import. The plugin runs on Shopware 6.5, 6.6 and 6.7 from a single ZIP.
Installation
From the administration
- Go to Extensions > My extensions.
- Click Upload extension and select the
DfRedirects-1.0.0.zipfile. - Click Install, then activate the extension.
From the command line
bin/console plugin:refresh
bin/console plugin:install --activate DfRedirects
bin/build-administration.sh
bin/console cache:clear
Building the administration is mandatory: without it, the DfRedirects module will not appear under the Content menu of your back office. On production use bin/build-administration.sh; in development, ./psh.phar administration:build or the equivalent command for your setup.
Installation creates two dedicated tables: df_redirect (your redirect rules) and df_redirect_404 (the log of missing URLs).
General configuration
Open Extensions > My extensions > DfRedirects > Configure. Three settings are available:
- Enable 404 logging: records the missing URLs your visitors hit. Enabled by default.
- Ignored patterns: one entry per line. Matching URLs are neither redirected nor logged. Wildcards are accepted (for example
/api-legacy/*); a plain string also works, it is searched for inside the URL. - Preserve query string: carries URL parameters (for example
?utm_source=newsletter) over to the target URL. Enabled by default, with no effect on 410 responses.
Requests to static resources are ignored out of the box: system folders (media, thumbnails, bundles, theme) and common file extensions (images, CSS, JS, fonts). You do not need to declare them in the ignored patterns.
Creating a redirect
The module lives under Content > Redirects in the administration. Click Add redirect and fill in:
- Source URL: the path to intercept, relative to the sales channel root (for example
/old-products/leather-sneakers). - Target URL: the destination path or absolute URL. This field is hidden for code 410.
- HTTP code: 301 (permanent), 302 (temporary), 307, 308 or 410 (page permanently gone).
- Match type: exact, wildcard or regex (see the next section).
- Priority: pattern evaluation order, from highest to lowest. No effect on exact matches.
- Sales channel: leave empty to apply the rule shop-wide, or pick a specific channel.
- Active: lets you disable a rule without deleting it.
The three matching modes
Exact
The source URL must match the requested path. A trailing slash is tolerated either way: /my-page and /my-page/ trigger the same rule. This is the preferred mode — it covers the vast majority of cases and is the fastest.
Wildcard
The asterisk * captures any portion of the URL. In the target URL, an asterisk at the same position reuses the captured value.
Source : /collection/summer-*
Target : /new-in/*
/collection/summer-dresses → /new-in/dresses
/collection/summer-shorts → /new-in/shorts
Regex
For the finest cases, enter a regular expression (without delimiters) and reference the captured groups in the target with $1, $2, and so on.
Source : ^/product/([0-9]+)-(.+)$
Target : /p/$2
Invalid expressions are rejected on save and on import: a broken rule cannot take your shop down.
Evaluation order
- Exact matches attached to the current sales channel.
- Global exact matches.
- Active wildcard and regex patterns, sorted by descending priority.
404 log
The 404 log tab lists every missing URL your visitors hit. Each entry is deduplicated: a given URL appears only once, with its hit count, the referer of the last visit and the date it was last seen. Sort by hit count to tackle the broken URLs costing you the most traffic first.
Two actions are available on each row:
- Create a redirect: opens the form with the source URL pre-filled and target suggestions already loaded. After saving, the 404 is automatically marked as resolved.
- Mark as resolved: files the entry without creating a rule, for example for a URL that never existed.
A Show resolved toggle brings processed entries back into view.
Target suggestions
As soon as you enter a source URL, the plugin proposes up to five destinations ranked by similarity score. The calculation compares the last segment of the broken URL to your canonical SEO URLs: a database pre-filter narrows the candidate pool, then a textual proximity score ranks them. Clicking a suggestion fills the target field.
Suggestions rely on the canonical, non-deleted SEO URLs of your shop. If your catalog has just been modified, regenerate Shopware’s SEO URLs before relying on the scores.
CSV import
The Import button opens a modal that accepts either a file or a direct paste. The expected format has five columns:
source;target;code;type;active
/old-page;/new-page;301;exact;1
/collection/summer-*;/new-in/*;301;wildcard;1
/removed-product;;410;exact;1
- Delimiter: semicolon or comma, auto-detected.
- Header row: optional, skipped when detected.
- Columns 3 to 5: optional. Defaults are code 301, exact type, active rule.
- Type: inferred automatically when the source contains an asterisk.
- Accepted codes: 301, 302, 307, 308 and 410. The target may stay empty for a 410.
The import works as an upsert: an existing rule with the same source URL is updated rather than duplicated. Imported rules are created with global scope (all channels). At the end, the plugin reports how many lines were created, updated and skipped, along with the details of any errors.
Performance tracking
Each rule counts its triggers and stores the date it last fired. A rule sitting at zero for several months can often be archived; conversely, a heavily used rule points to an old URL still widely circulated, which may be worth fixing at the source (backlink, campaign, printed catalog).
Troubleshooting
The module does not appear under the Content menu
The administration build was not run after installation. Run bin/build-administration.sh, then clear your browser cache.
A redirect does not fire
- Check that the rule is active and that its sales channel matches (or that it is global).
- Check that the source URL is relative to the channel root: on a channel served from a subfolder, do not include the domain prefix.
- Check that no ignored pattern covers this URL.
- Clear the cache:
bin/console cache:clear. - Make sure no redirect is already applied upstream by your web server or CDN — in that case the request never reaches Shopware.
The 404 log stays empty
Check that Enable 404 logging is ticked in the plugin configuration, and that your ignored patterns are not too broad. Remember that static resources are excluded by design.
A redirect loop
This happens when a rule points to a URL that is itself redirected back, directly or through an overly broad wildcard pattern. Search for the target URL in the list of sources and tighten the offending pattern.
Uninstalling
When uninstalling, Shopware offers to keep the data. If you untick that option, the df_redirect and df_redirect_404 tables are permanently dropped, along with all your rules and the 404 history. Export your rules beforehand if you plan to reinstall.