Skip to content
SEO Extensions

Redirects & 404 Logger for Magento 2

Add literal, regex and maintenance redirect rules with eight HTTP status codes, create a 301 when a product, category or CMS page is deleted, and log 404s to see which paths need a redirect.

  • Free
  • Themes listed: Hyvä + Luma
Free $0.00, in stock
Check requirementsSee the versions and themes listed for this package. Details Ask about setupInclude the package name and your Magento and PHP versions. Ask
$0.00
In stock
SKU
panth-redirects
Links
composer require mage2kishan/module-redirects
SKU
panth-redirects
  • Package requirementsRead the source documentation
  • Developer profileView Upwork profile
  • Themes listedHyvä + Luma
  • PHP versions listed8.1, 8.2, 8.3, 8.4
  • Installation questionsDiscuss your store setup

What it does for your store

The main features, as listed in the module documentation.

  • Literal, regex and maintenance rules

    Match exact paths, PCRE patterns with $1 references, or answer a path with HTTP 503 during maintenance.

  • Eight status codes

    Send 301, 302, 303, 307, 308, 410, 451 or 503, with store view, priority and an optional date window per rule.

  • Redirects on delete

    Create a 301 when a product, category or CMS page is deleted, pointing to a parent category, the homepage or a custom path.

  • 404 log and clusters

    Log unmatched paths with referer and hit count, then review a daily grouping of the last seven days of 404s.

  • CSV import and export

    Import with loop checks and row errors, export every rule, or use the console command with a dry run.

Installation

Example commands from the Magento root. Follow the package instructions and your staging and deployment process.

  1. 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
  2. 2Install on stagingReview Composer changes and follow the package instructions.
  3. 3Configure and verifyUse the documented settings and test the affected features.
magento-root
$ composer require mage2kishan/module-redirects
$ bin/magento setup:upgrade
$ bin/magento setup:di:compile
$ bin/magento setup:static-content:deploy -f
$ bin/magento cache:clean

Listed requirements

These are the details supplied in this listing. Confirm the selected release supports your Magento edition, PHP and storefront.

Magento versions listed2.4.6, 2.4.7, 2.4.8
PHP versions listed8.1, 8.2, 8.3, 8.4
Themes listedHyvä, Luma
Composer packagemage2kishan/module-redirects

Read package requirements and license

Documentation

Product details and setup guidance. Check the package repository for release-specific instructions.

Redirect rules and a 404 log in the Magento admin

Redirects for Magento 2 adds a redirect manager and a 404 log to the Magento admin. Magento's own URL rewrites cover one exact request path per row, and only for catalog and CMS entities that Magento still knows about. This module keeps its own rule table and checks it on storefront GET requests before the controller runs, so a rule can match a path that no longer exists, match by regular expression, send a status code other than 301 or 302, run only inside a date window and count how often it fires.

It suits store owners and SEO teams who restructure a catalog, retire products or move from another platform, and developers who need to load a large set of redirects from a CSV file. The module ships no storefront templates or assets, so it behaves the same on Hyvä and Luma.

Three match types and eight status codes

Each rule has a request path, a target, a status code, a match type, a store view, a priority, an active flag and an optional Active From and Active Until window.

  • Literal rules compare the normalized path exactly, with the query string removed and the trailing slash dropped.
  • Regex rules use a PCRE pattern, and the target can insert captured groups with $1 style references.
  • Maintenance rules answer with HTTP 503, a Retry-After header and the target text as the body.

The supported status codes are 301, 302, 303, 307, 308, 410, 451 and 503. For 410, 451 and 503 the target text is sent as a plain text body with no Location header. Absolute targets are only followed when the host matches one of your store view base URLs, and targets with a javascript, data or vbscript scheme are rejected.

Literal rules are looked up first. If none matches, regex and maintenance rules are tried in priority order and the first match inside its date window wins. Rules for all store views and for the current store view are merged before matching, so priority decides between them.

Redirects when you delete a product, category or CMS page

With the default settings, deleting a product creates a literal 301 rule for each of its URL rewrites, pointing to its first category, the homepage or a custom path, depending on the Redirect Target Strategy setting. Deleting a category points its URLs to the parent category, or to the homepage when the parent is a root category. Deleting a CMS page points it to the homepage. Redirects for a changed URL key are left to Magento's own Create Permanent Redirect for URLs if URL Key Changed option.

Three optional canonical redirects run before rule matching: uppercase paths to lowercase, homepage aliases such as /index.php and /home to the base URL, and trailing slash removal. The first two are on by default and trailing slash removal is off. Checkout, customer, sales, REST, GraphQL, admin, static and media routes are never redirected by the lowercase or trailing slash options.

Find the 404s that need a redirect

Requests that reach Magento's no-route handler and match no rule are written to the 404 log with the store view, path, referer, user agent, hit count and first and last seen times. Repeat hits on the same path add to the count instead of adding rows, and a per IP rate limit caps how many log writes are accepted each second.

A daily job reads up to 500 of the most hit paths from the last seven days, groups them by a pattern where digit runs become {n}, and shows the result in the 404 Clusters grid. A cluster such as /catalog/product/view/id/{n} can become a single regex rule. The log does not create redirects for you; you decide which paths need one.

CSV import and export

The Import CSV screen explains the format and offers a sample file. Files up to 10 MB are accepted, and rows with an unknown match type or status code, an empty pattern or target, a regex that does not compile or a literal rule that would cause a redirect loop are skipped and reported. Export CSV downloads every rule in the same column layout. Values that start with a spreadsheet formula character are escaped on export.

For larger files, run bin/magento panth:redirects:import with a file path. The --dry-run option validates the file and prints the counts and row errors without writing anything.

Cleanup and caching

A daily cleanup job deletes automatically created rules whose Active Until date has passed, and automatically created rules with no hits that are older than Redirect Expiry Days (365 by default). Rules you create in the admin or import are never deleted by this job. Saving, deleting or importing rules clears the rule cache and the related full page cache entries. Pages already held in Varnish or the built-in page cache are not checked again until they expire or are cleared.

Requirements and installation

The package requires PHP 8.1 to 8.4, magento/framework ^103.0 with the Store, Backend, Catalog, CMS, URL Rewrite, UI and Config modules, and mage2kishan/module-core. Its README lists Magento Open Source and Adobe Commerce 2.4.4 to 2.4.8. Magento cron must be running for the cleanup and cluster jobs. Install it with Composer:

composer require mage2kishan/module-redirects
bin/magento module:enable Panth_Core Panth_Redirects
bin/magento setup:upgrade
bin/magento cache:flush

Run setup:di:compile in production mode. The module is active as soon as it is installed, so review the defaults under Stores, Configuration, Panth Extensions, Redirects and 404s on staging first. Uninstalling keeps the panth_seo_redirect, panth_seo_404_log and panth_seo_404_cluster tables.

The package is free and released under the MIT license. Read the package README and changelog for the release you install.

Developer notes

These names are from release 1.2.8 of the package.

  • Namespace Panth\Redirects. mage2kishan/module-advanced-seo lists this package under suggest and does not require it.
  • Api\RedirectMatcherInterface (implemented by Model\Redirect\Matcher) exposes match(), recordHit() and log404(). Api\Data\RedirectRuleInterface describes a rule row.
  • Observer\Redirect\Predispatch on controller_action_predispatch (frontend area) matches rules and sends the response.
  • Service\RedirectGuard::isSafeToRedirect() allows only GET requests on the frontend area. It rejects XHR, JSON and non-navigate requests and admin URLs, and skips paths starting with /rest/, /soap/, /graphql, /V1/, /static/, /media/, /pub/, /errors/, /health_check, /sitemap, /robots.txt and /favicon.ico.
  • Frontend plugins: HomepageRedirectPlugin, LowercaseRedirectPlugin and TrailingSlashRedirectPlugin around FrontControllerInterface::dispatch; NoRouteLoggerPlugin after NoRouteHandler::process.
  • Plugin\UrlRewrite\RouterXhrGuard around Magento\UrlRewrite\Controller\Router::match returns null for requests the guard rejects when the matching url_rewrite row is a redirect. Normal rewrites still resolve.
  • Observers ProductDeleteBefore, CategoryDeleteBefore and CmsPageDeleteBefore listen to model_delete_before in the global area.
  • Services: Model\Redirect\ImportExport, Model\Redirect\AutoRedirectService and Model\Redirect\Loop (loop detection for literal rules, depth limit 25). Cron: Cron\RedirectCleanup and Cron\NotFoundCluster.
  • Saving, enabling, disabling, deleting or importing rules goes through Model\Redirect\RuleCache, which dispatches clean_cache_by_tags with the FPC tag. Magento's built-in page cache stores every entry with that tag, so the whole built-in page cache is cleared. In Varnish mode the same event sends a ban for FPC, but core adds that tag only to built-in cache entries, so pages already in Varnish are not expected to be removed. After changing rules, purge the affected URLs and confirm with a request.
  • ACL resources: Panth_Redirects::manage, ::redirects, ::not_found_log, ::not_found_cluster and ::config.
  • Admin route panth_redirects. UI components: panth_redirects_redirect_listing, panth_redirects_redirect_form, panth_redirects_notfoundlog_listing and panth_redirects_notfoundcluster_listing.
  • The panth_seo_* table names are kept from Panth_AdvancedSEO so its data stays available. panth_seo_redirect and panth_seo_404_cluster have foreign keys to store with cascade delete. panth_seo_404_log is unique per store_id and path_hash.
More information
Module Category SEO & Indexing
Best For All Sizes

Changelog

  1. 1.2.8, 2026-10-30

    • Released under the MIT License: this module is free and open-source software.
  2. 1.2.7, 2026-10-06

    • Real product, category and CMS URLs no longer return 404 to XHR, fetch and other non-navigation requests (for example when a page is loaded by script right after the page cache was cleaned). The guard on Magento's URL rewrite router now only skips rewrites that redirect (301 or 302) for those requests, and those 404s are no longer written to the 404 log.
    • The trailing slash and lowercase redirects no longer apply to Magento system routes (checkout, customer, sales, wishlist, multishipping, paypal, payment, braintree, catalogsearch, rest, soap, graphql, admin, static and media), so /checkout/cart/ is served directly instead of being redirected to /checkout/cart. Non-GET requests were already excluded.
Full history on GitHub
Kishan Savaliya

Questions before you install?

Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.

Ask on WhatsApp