Download the PHP package autologic-web/redirect-bundle without Composer
On this page you can find all versions of the php package autologic-web/redirect-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download autologic-web/redirect-bundle
More information about autologic-web/redirect-bundle
Files in autologic-web/redirect-bundle
Package redirect-bundle
Short Description A Symfony bundle for handling redirection
License MIT
Informations about the package redirect-bundle
Symfony Redirect Bundle
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 ^2.7, ^3.0 or ^4.0 with PHP ^5.6 or ^7.0
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
Install via Composer
Symfony < 4
Include the bundle in AppKernel.php
Symfony 4
Include the bundle in bundles.php
Configuration
Basic Usage
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)
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.
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)
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)
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)
Force the redirect protocol (default: null/auto). If left unset, it will detect the protocol from the original request and use that.
Other Examples
Logging
To enable logging of unmatched 404 errors, just inject a logger into the listener service in your services.yml:
This will log at notice
level to help sniff out 404s that don't have any redirection rules in place.
All versions of redirect-bundle with dependencies
symfony/http-foundation Version ^2.7|^3.0|^4.0
symfony/config Version ^2.7|^3.0|^4.0
symfony/dependency-injection Version ^2.7|^3.0|^4.0
symfony/http-kernel Version ^2.7|^3.0|^4.0