Download the PHP package jidoka1902/redirecting-fallbacks-symfony without Composer
On this page you can find all versions of the php package jidoka1902/redirecting-fallbacks-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jidoka1902/redirecting-fallbacks-symfony
More information about jidoka1902/redirecting-fallbacks-symfony
Files in jidoka1902/redirecting-fallbacks-symfony
Package redirecting-fallbacks-symfony
Short Description Integration to the jidoka1902/redirecting-fallbacks project for symfony
License BSD-3-Clause
Informations about the package redirecting-fallbacks-symfony
redirecting-fallbacks-symfony
Symfony Integration for the "redirecting-fallbacks" project.
Examples
It's all about the configuration.
Basic Configuration
First of all, load the integration and library classes as services. So you can wire them as you need.
After that you can decide what type of routes you want to specify in your configuration files. Either plain paths like "/" and "/blog" or symfony named routes like "app_index".
For Symfony Routing - use the provided FrameworkUrlGeneratorAdapter:
If you prefer plain paths to redirect to use this config:
Gloal Redirect on 404
Now that you know how to configure your prefered path-type - let's have a basic example about one redirect path for all occuring 404 Status Reasons (NotFoundHttpException or plain ResponseCode 404).
-
you have to wire the SingleRedirectResolver as alias for the RedirectResolver interface.
- configure the route to redirect to
è voila! every request resulting in a 404 state will be redirected to "/"
More Precise Redirects depending on Paths
After that basic configuration, lets have a look at how to create more individual 404-redirects. E.g. if someone enters an not found blog url because of a wrong slug which was not found in your storage, should that be redirected to the start-page or do you have a fancy blog post search site? Same here:
-
link your desired RedirectResolver:
- configure it:
But beware! the order of your mappings plays a role.
All versions of redirecting-fallbacks-symfony with dependencies
jidoka1902/redirecting-fallbacks Version ^1.0.1
symfony/routing Version ^3.4|^4.0
symfony/event-dispatcher Version ^3.4|^4.0
symfony/http-foundation Version ^3.4|^4.0
symfony/http-kernel Version ^3.4|^4.0