phil / redirects-bundle
Redirects managed in an admin for Symfony: exact, prefix and wildcard sources resolved only when nothing else answered, old domains mapped to a new host, loops and chains refused on save, external targets limited to allowed hosts, a log of paths not found with no visitor data, CSV import and export,
Package info
github.com/parler-haut-interagir-librement/redirects-bundle
Type:symfony-bundle
pkg:composer/phil/redirects-bundle
Requires
- php: >=8.5
- ext-ctype: *
- ext-mbstring: *
- doctrine/dbal: ^4.5
- doctrine/orm: ^3.7
- phil/url: ^0.1.3@dev
- psr/cache: ^3.0
- psr/clock: ^1.0
- psr/log: ^3.0
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/http-foundation: ^8.2
- symfony/http-kernel: ^8.2
- symfony/routing: ^8.2
Requires (Dev)
- doctrine/doctrine-bundle: ^3.3
- easycorp/easyadmin-bundle: ^5.8
- phil/bot-detection-bundle: ^0.1@dev
- phpunit/phpunit: ^13.4
- symfony/cache: ^8.2
- symfony/clock: ^8.2
- symfony/console: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/security-core: ^8.2
- symfony/security-csrf: ^8.2
- symfony/service-contracts: ^3.6
- symfony/translation: ^8.2
- symfony/translation-contracts: ^3.6
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- twig/twig: ^3.21
Suggests
- easycorp/easyadmin-bundle: For the links of the administration in an EasyAdmin back office
- phil/bot-detection-bundle: For the robot verdict that keeps a robot's 404 out of the log
- symfony/cache: For a PSR-6 pool that keeps the table of redirects between requests
- symfony/console: For phil:redirects:import, export, check and purge-404
- symfony/security-core: For the role that guards the administration
- symfony/security-csrf: For the CSRF token of the administration's forms
- symfony/translation: For the administration in English and French
- twig/twig: For the administration's pages
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 21:54:39 UTC
README
Redirects for Symfony, managed from an administration and resolved only when nothing else answered.
phil/redirects-bundle keeps the redirects of a site that moved: 301, 302, 307, 308 and 410 Gone, from an
exact path, a prefix or a wildcard source, to a path, an allowed absolute URL or a route. It resolves them on a 404
only, so a page that exists never pays for the table, and maps whole old domains to a new host before the routing.
Loops and chains are refused when a redirect is saved, and no redirect leaves the site unless the application listed
the host. The paths that were not found are logged by host and path, without any visitor data, and turned into a
redirect from the administration in one click. Redirects come and go as CSV, from the administration or the console,
and other packages contribute their own through a provider.
It is the redirect table of any site whose addresses change: a new structure, a merged section, a domain left behind.
Status
| Part | State |
|---|---|
| Sources (exact, prefix, wildcard, regular expression) and targets (path, URL, route, gone) | Implemented and tested |
The table, its PSR-6 cache and the resolver on 404 |
Implemented and tested, benchmarked on 10,000 redirects |
| Old domains before the routing | Implemented and tested |
| Loops, chains and open redirects refused when saving | Implemented and tested |
| The 404 log, its filters and its purge | Implemented and tested |
| The administration in Twig, in English and French, and the EasyAdmin menu | Implemented and tested |
CSV import and export, phil:redirects:import, export, check, purge-404 |
Implemented and tested |
| Providers for the redirects of other packages | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, registering the bundle, the tables, the routes of the administration. |
| Configuration | Every option of phil_redirects. |
| Sources and targets | The four kinds of source, their bounded syntax, the targets and their placeholders. |
| Resolution | When a redirect answers, in which order, its precedence after the routes of other packages, the cache. |
| Old domains | A domain mapped to a new host before the routing. |
| Safety | Loops and chains, open redirects, regular expressions, the bounds of every input. |
| The 404 log | What is kept and what is not, the filters, the robot verdict, the purge. |
| Administration | The pages, the role, the CSRF token, the layout, EasyAdmin. |
| Import, export and commands | The CSV format and the four commands. |
| Extension points | Providers, filters, repositories and options an application chooses or replaces. |
| Testing | The tests, the mutation bar, the fuzz target and the benchmark. |
| Reference | Every type of the bundle, with its role. |
Quick start
composer require phil/redirects-bundle
# config/packages/phil_redirects.yaml phil_redirects: allowed_hosts: [shop.example.com] cache: { pool: cache.app } old_domains: old-example.com: { host: www.example.com } admin: { enabled: true, role: ROLE_EDITOR }
# config/routes/phil_redirects.yaml phil_redirects_admin: resource: '@PhilRedirectsBundle/config/routes/admin.php' prefix: /admin/redirects
use Phil\RedirectsBundle\Application\Redirects; use Phil\RedirectsBundle\Domain\ValueObject\RedirectRule; use Phil\RedirectsBundle\Domain\ValueObject\SourcePattern; use Phil\RedirectsBundle\Domain\ValueObject\Target; $redirects->create(new RedirectRule(SourcePattern::wildcard('/blog/*/**'), Target::url('/articles/$1')));
Requirements
PHP 8.5 or later, Symfony 8.2 or later, Doctrine DBAL 4.5 or later and phil/url 0.1.3, which requires the intl,
mbstring and URI extensions. The console, Twig, the security, the translator, a PSR-6 pool, EasyAdmin and
phil/bot-detection-bundle are optional.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.