PHPackages                             smirnov-tk/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. [HTTP &amp; Networking](/categories/http)
4. /
5. smirnov-tk/redirect-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

smirnov-tk/redirect-bundle
==========================

A Symfony bundle for handling redirection

0.3.3(4y ago)1221MITPHPPHP &gt;=7.1.3, &lt;8.2

Since Oct 16Pushed 4y agoCompare

[ Source](https://github.com/smirnov-tk/redirect-bundle)[ Packagist](https://packagist.org/packages/smirnov-tk/redirect-bundle)[ RSS](/packages/smirnov-tk-redirect-bundle/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (6)Versions (15)Used By (0)

Symfony Redirect Bundle
=======================

[](#symfony-redirect-bundle)

[![Build Status](https://camo.githubusercontent.com/8f31ec4d55a73550cedec72552f86040971bf5f67a3865f9038ba778c089ca5f/68747470733a2f2f6170702e7472617669732d63692e636f6d2f736d69726e6f762d746b2f72656469726563742d62756e646c652e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/smirnov-tk/redirect-bundle) [![Maintainability](https://camo.githubusercontent.com/08375b63a600e2bfeeb21502435576226db9675706f5f42894e0a7d31001fea6/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66616639643533616139353935643637653631322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/smirnov-tk/redirect-bundle/maintainability) [![Test Coverage](https://camo.githubusercontent.com/0bccbe465baa7fd2c0f2b2fd5a229393eb247477a40094989b4c92817e3ff89b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66616639643533616139353935643637653631322f746573745f636f766572616765)](https://codeclimate.com/github/smirnov-tk/redirect-bundle/test_coverage)

Configure redirections after a migration or structural changes to your app/website.

It catches exception events, if they are of type `NotFoundHttpException` it will look for a configured rule and return a `RedirectResponse` response to redirect the user.

Works for Symfony ^4.2 or ^5.0 with PHP &gt;= 7.1.3 and &lt;8.2

It's been designed to be as unobtrusive as possible since the need to do this sort of thing is often temporary - Google recommends leaving them in place for a year. Just include the bundle and add a block of configuration for your redirect rules.

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

[](#installation)

Install via Composer

```
$ composer require smirnov-tk/redirect-bundle
```

Include the bundle in `bundles.php`

```
# config/bundles.php

return [
    // All your bundles

    Autologic\Bundle\RedirectBundle\AutologicRedirectBundle::class => ['all' => true],
];
```

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

[](#configuration)

### Basic Usage

[](#basic-usage)

```
# app/config/packages/autologic_redirect.yaml

autologic_redirect:
  rules:
    - { pattern: '/old-route/', redirect: 'domain.com/new-route' }
```

### `pattern` (string, required)

[](#pattern-string-required)

Use regular expressions to match the full URI being requested. The service catches 404 exceptions, uses `preg_match` to find a rule matching the missing page's URI before throwing the 404 in the event it cannot match.

### `redirect` (string, required)

[](#redirect-string-required)

The fully qualified redirect URI. The bundle will set the protocol (http/https) based on the incoming original request so it ports from dev to prod easily.

### `full_url` (bool, optional)

[](#full_url-bool-optional)

Defines whether to match pattern on full URL (with scheme, domain, path and query) or only path and query (\_**default: false**)

### `status` (int, optional)

[](#status-int-optional)

Set the status code (**default: 301**) for the redirection. Tip: use 302 while debugging to avoid 301 permanent redirects from being cached in the browser.

### `forwarding` (bool, optional)

[](#forwarding-bool-optional)

Append the original route to the redirection (**default: false**). Useful in the case that other services/applications have their own redirect logic in place or route structure is the same on a different domain or path.

### `absolute` (bool, optional)

[](#absolute-bool-optional)

Force absolute or relative redirects (**default: null/auto**). If left unset, it will detect a hostname in the redirect and either use the original request host if the redirect does not contain a host or use the redirect verbatim if it does.

### `protocol` (string, optional)

[](#protocol-string-optional)

Force the redirect protocol (**default: null/auto**). If left unset, it will detect the protocol from the original request and use that.

### Other Examples

[](#other-examples)

```
# app/config.yml

autologic_redirect:
  rules:
    # custom status code
    - { pattern: '/old-route/', redirect: 'domain.com/new-route', status: 302 }
    # forwarding: this will redirect to domain.com/new-route/old-route
    - { pattern: '/old-route/', redirect: 'domain.com/new-route', forwarding: true }
    # absolute: will force relative or absolute redirects
    # if false it will redirect to the route on the current host
    - { pattern: '/old-route/', redirect: '/new-route', absolute: false }
    # protocol: will force the protocol
    - { pattern: '/old-route/', redirect: '/new-route', protocol: 'ftp://' }
    # priority: this first rule will match first when a user visits /old-route/sub-route, the second acting as a fallback
    - { pattern: '/.*old-route\/sub-route', redirect: 'domain.com/new-route/sub-route' }
    - { pattern: '/.*old-route/', redirect: 'domain.com/new-route' }
    # match subdomains and more complex patterns and use parameters
    - { pattern: '/au\..+?\.[^\/]+.*blog\/old-australian-blog-post-on-any-domain-of-subdomain/',
        redirect: 'au.%base_domain%/news/new-australian-news-article',
        full_url: true
      }
```

Logging
-------

[](#logging)

To enable logging of unmatched 404 errors, just inject a logger into the listener service in your services.yml:

```
# app/services.yml

services:
  autologic_redirect.event.redirect_listener:
    class: Autologic\Bundle\RedirectBundle\Event\RedirectListener
    arguments:
      - '@autologic_redirect.service.redirect_service'
      - '@logger'
    tags:
      - { name: kernel.event_listener, event: kernel.exception }
```

This will log at `notice` level to help sniff out 404s that don't have any redirection rules in place.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~165 days

Recently: every ~0 days

Total

11

Last Release

1469d ago

PHP version history (5 changes)0.1.0PHP ^7.0

0.2.0PHP ^5.6 || ^7.0

0.2.1PHP ^5.6|^7.0

0.2.4PHP &gt;=5.6, &lt;8.2

0.3.0PHP &gt;=7.1.3, &lt;8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6261028?v=4)[Roman Smirnov](/maintainers/smirnov-tk)[@smirnov-tk](https://github.com/smirnov-tk)

---

Top Contributors

[![smirnov-tk](https://avatars.githubusercontent.com/u/6261028?v=4)](https://github.com/smirnov-tk "smirnov-tk (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)

PHPackages © 2026

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