PHPackages                             jainamdeveloper/magento2-custom-redirect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jainamdeveloper/magento2-custom-redirect

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

jainamdeveloper/magento2-custom-redirect
========================================

Magento 2 module that recovers 404 visitors with intelligent 301 redirects. Disabled category redirects to nearest active parent, removed product redirects to active category. Full multi-store and multi-website support.

1.0.2(1mo ago)06MITPHPPHP ^8.1

Since Oct 31Pushed 1mo agoCompare

[ Source](https://github.com/JainamDeveloper/magento2-custom-redirect)[ Packagist](https://packagist.org/packages/jainamdeveloper/magento2-custom-redirect)[ RSS](/packages/jainamdeveloper-magento2-custom-redirect/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (6)Versions (6)Used By (0)

Magento 2 Custom Redirect — 404 NoRoute Handler
===============================================

[](#magento-2-custom-redirect--404-noroute-handler)

A lightweight Magento 2 module that automatically recovers visitors from 404 pages by redirecting them to the most relevant active page using 301 redirects. Instead of bouncing customers to a dead end, this module intelligently resolves deleted or disabled URLs to their best matching destination.

Why Use This Module
-------------------

[](#why-use-this-module)

When you restructure your Magento 2 store — disable categories, remove products, or migrate from a legacy URL structure — customers and search engines hit 404 pages. Every 404 is a lost visitor and a wasted SEO signal.

This module intercepts every NoRoute (404) request in Magento 2 and resolves it automatically:

- Disabled or deleted category URL: visitor lands on the nearest active parent category, staying in the right section of the store
- Removed product URL: visitor lands on an active category the product belonged to, so they can still browse alternatives
- Legacy URL patterns (e.g. `view-shape/`): old external links and bookmarks resolve directly to the correct product page
- Unresolvable 404: visitor is sent to the store homepage — no dead ends, no lost sessions

Net result: fewer exits, preserved SEO link equity via 301 signals, and old URLs never fully break.

How It Works
------------

[](#how-it-works)

The module registers an `aroundPlugin` on `Magento\Cms\Controller\Noroute\Index::execute`. On every 404 request in Magento 2:

1. Looks up the requested path in the `url_rewrite` table
2. If a rewrite exists, determines entity type (category or product) and finds the best active redirect target
3. If no rewrite exists, checks legacy URL patterns
4. Falls back to the store homepage if no valid target is found

All redirects are issued as HTTP 301 (permanent), so search engines transfer link equity to the new URL.

Requirements
------------

[](#requirements)

- Magento 2.4.4 – 2.4.9
- PHP 8.1 – 8.5

Installation
------------

[](#installation)

### Via Composer (recommended)

[](#via-composer-recommended)

```
composer require jainamdeveloper/magento2-custom-redirect
bin/magento module:enable Magneto_CustomRedirect
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
```

### Manual Installation

[](#manual-installation)

1. Copy the module files to `app/code/Magneto/CustomRedirect/`
2. Run the following commands:

```
bin/magento module:enable Magneto_CustomRedirect
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
```

Redirect Logic Reference
------------------------

[](#redirect-logic-reference)

Incoming URL typeRedirect TargetDisabled/deleted categoryNearest active parent categoryRemoved/disabled productFirst active category the product belonged toLegacy `view-shape/` URLProduct URL resolved by SKUAny other 404Store homepageKeywords
--------

[](#keywords)

Magento 2 custom redirect, Magento 2 404 redirect, Magento 2 NoRoute plugin, Magento 2 301 redirect, Magento 2 SEO redirect, Magento 2 category redirect, Magento 2 product redirect, Magento 2 URL rewrite redirect, Magento 2 404 handler, Magento 2 page not found redirect

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Total

3

Last Release

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/610205?v=4)[Jainam](/maintainers/jainamshah)[@JainamShah](https://github.com/JainamShah)

---

Top Contributors

[![JainamDeveloper](https://avatars.githubusercontent.com/u/43310942?v=4)](https://github.com/JainamDeveloper "JainamDeveloper (10 commits)")[![vishalbytes](https://avatars.githubusercontent.com/u/104197090?v=4)](https://github.com/vishalbytes "vishalbytes (7 commits)")

---

Tags

magento2magento2-extensionmagento2-modulemagento2-module-free

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jainamdeveloper-magento2-custom-redirect/health.svg)

```
[![Health](https://phpackages.com/badges/jainamdeveloper-magento2-custom-redirect/health.svg)](https://phpackages.com/packages/jainamdeveloper-magento2-custom-redirect)
```

###  Alternatives

[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68357.9k](/packages/run-as-root-magento2-prometheus-exporter)[angeo/module-llms-txt

Magento 2 module for AI Engine Optimization (AEO). Generates spec-compliant llms.txt and llms-full.txt per llmstxt.org standard, plus streaming JSONL for vector indexing. Multi-store, multi-website, CLI, cron, async admin UI, Page Builder-aware sanitization, customer-group pricing, atomic writes, ETag/Cache-Control, .md mirrors.

111.1k](/packages/angeo-module-llms-txt)[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)[customgento/module-cookiebot-m2

This Magento 2 module integrates Cookiebot into your store.

2471.0k](/packages/customgento-module-cookiebot-m2)[opengento/module-category-import-export

This module add the capability to import and export the categories from the back-office.

1310.9k2](/packages/opengento-module-category-import-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
