PHPackages                             zenstruck/redirect-bundle - 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. zenstruck/redirect-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

zenstruck/redirect-bundle
=========================

Store redirects for your site and keeps statistics on redirects and 404 errors

v3.11.0(4mo ago)2661.7k↓43.8%8[2 issues](https://github.com/zenstruck/redirect-bundle/issues)1MITPHPPHP &gt;=8.1CI failing

Since Aug 21Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/zenstruck/redirect-bundle)[ Packagist](https://packagist.org/packages/zenstruck/redirect-bundle)[ Docs](https://github.com/kbond/ZenstruckRedirectBundle)[ GitHub Sponsors](https://github.com/kbond)[ GitHub Sponsors](https://github.com/nikophil)[ RSS](/packages/zenstruck-redirect-bundle/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (29)Used By (1)

ZenstruckRedirectBundle
=======================

[](#zenstruckredirectbundle)

[![CI](https://github.com/zenstruck/redirect-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/zenstruck/redirect-bundle/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/2464125cef5775e4df9902157321c41f4d09f6843f484e78f239e44549831ebd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e73747275636b2f72656469726563742d62756e646c652e737667)](https://packagist.org/packages/zenstruck/redirect-bundle)[![Total Downloads](https://camo.githubusercontent.com/00dbbc08ff7f7df90a8eee643c2999de30c7a7f1e0cc7932cd196df8b53fbfc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e73747275636b2f72656469726563742d62756e646c652e737667)](https://packagist.org/packages/zenstruck/redirect-bundle)

This bundle adds entities for redirects and 404 errors.

For redirects, 404 errors are intercepted and the requested path is looked up. If a match is found it redirects to the found redirect's destination. The count and last accessed date are updated as well. A redirect form type and validation is available as well.

404 errors can be logged as well. Each 404 error is it's own record in the database. The path, full URL, timestamp, and referer are stored. Storing each error as a separate record allows viewing statistics over time and seeing all the referer URLs. When a redirect is created or updated, 404 records that match it's path are deleted.

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

[](#installation)

1. Install with composer:

```
composer require zenstruck/redirect-bundle
```

2. Enable the bundle: This Step is only needed if you are not using [Symfony Flex](https://symfony.com/doc/current/setup/flex.html).

    ```
    // config/bundles.php

    return [
            // ...
            Zenstruck\RedirectBundle\ZenstruckRedirectBundle::class => ['all' => true],
        ];
    ```

Configuration
-------------

[](#configuration)

**NOTE:** A `NotFound` or `Redirect` or both must be configured.

### Redirect

[](#redirect)

1. Create your redirect class inheriting the MappedSuperClass this bundle provides:

    ```
    namespace App\Entity;

    use Zenstruck\RedirectBundle\Model\Redirect as BaseRedirect;
    use Doctrine\ORM\Mapping as ORM;

    /**
     * @ORM\Entity
     * @ORM\Table(name="redirects")
     */
    class Redirect extends BaseRedirect
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    }
    ```
2. Set this class in your `zenstruck_redirect.yml`:

    ```
    zenstruck_redirect:
        redirect_class: App\Entity\Redirect
    ```
3. Update your schema (or use a migration):

```
bin/console doctrine:schema:update --force
```

### NotFound

[](#notfound)

1. Create your not found class inheriting the MappedSuperClass this bundle provides:

    ```
    namespace App\Entity;

    use Zenstruck\RedirectBundle\Model\NotFound as BaseNotFound;
    use Doctrine\ORM\Mapping as ORM;

    /**
     * @ORM\Entity
     * @ORM\Table(name="not_founds")
     */
    class NotFound extends BaseNotFound
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    }
    ```
2. Set this class in your `zenstruck_redirect.yml`:

    ```
    zenstruck_redirect:
        not_found_class: App\Entity\NotFound
    ```
3. Update your schema (or use a migration):

```
bin/console doctrine:schema:update --force
```

Form Type
---------

[](#form-type)

This bundle provides a form type (`zenstruck_redirect`) for creating/editing redirects.

```
$redirect = // ...
$form = $this->createForm('zenstruck_redirect', $redirect);
```

You may want to disable the `source` field for already created redirects:

```
// new action
$redirect = new Redirect();
$form = $this->createForm('zenstruck_redirect', $redirect);

// edit action
$redirect = // get from database
$form = $this->createForm('zenstruck_redirect', $redirect, array('disable_source' => true));
```

Full Default Configuration
--------------------------

[](#full-default-configuration)

```
zenstruck_redirect:
    redirect_class:     ~ # Required if not_found_class is not set
    not_found_class:    ~ # Required if redirect_class is not set
    model_manager_name: ~

    # When enabled, when a redirect is updated or created, the NotFound entities with a matching path are removed.
    remove_not_founds: true
```

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance78

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.2% 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 ~180 days

Recently: every ~201 days

Total

28

Last Release

92d ago

Major Versions

1.x-dev → v2.0.02015-06-08

2.x-dev → v3.0.02015-10-23

v3.7.2 → 4.x-dev2023-08-17

PHP version history (6 changes)v3.1.0PHP ^5.6|^7.0

v3.4.0PHP &gt;=7.1.3

v3.5.0PHP &gt;=7.2.5

v3.6.0PHP &gt;=7.4

v3.7.0PHP &gt;=8.0

v3.11.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/707369cc916e0ea1aacbf077dcba464f611cef879f024d8944311a54a15224b3?d=identicon)[kbond](/maintainers/kbond)

---

Top Contributors

[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (145 commits)")[![napestershine](https://avatars.githubusercontent.com/u/8603325?v=4)](https://github.com/napestershine "napestershine (2 commits)")[![sadikoff](https://avatars.githubusercontent.com/u/213810?v=4)](https://github.com/sadikoff "sadikoff (2 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (2 commits)")[![emirii](https://avatars.githubusercontent.com/u/6307976?v=4)](https://github.com/emirii "emirii (1 commits)")[![GwendolenLynch](https://avatars.githubusercontent.com/u/1427081?v=4)](https://github.com/GwendolenLynch "GwendolenLynch (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")

---

Tags

phpredirectseosymfonysymfony-bundleredirect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zenstruck-redirect-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/zenstruck-redirect-bundle/health.svg)](https://phpackages.com/packages/zenstruck-redirect-bundle)
```

###  Alternatives

[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[setono/sylius-redirect-plugin

Sylius plugin for managing redirects

26352.1k](/packages/setono-sylius-redirect-plugin)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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