PHP code example of samsonasik / expressive-redirect-handler
1. Go to this page and download the library: Download samsonasik/expressive-redirect-handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samsonasik / expressive-redirect-handler example snippets
use Laminas\Diactoros\Response\RedirectResponse;
// ...
$redirect = '/foo'; // may be a variable from GET
return new RedirectResponse($redirect);
return [
'expressive-redirect-handler' => [
'allow_not_routed_url' => false,
'default_url' => '/',
'options' => [
'exclude_urls' => [
// 'https://www.github.com/samsonasik/ExpressiveRedirectHandler',
], // to allow excluded urls to always be redirected
'exclude_hosts' => [
// 'www.github.com'
],
],
],
// ...
];
return [
'expressive-redirect-handler' => [
'allow_not_routed_url' => false,
'default_url' => '/',
'header_handler' => [
'enable' => true, // enable it!
'headers' => [
401 => '/login',
503 => '/maintenance',
],
],
],
// ...
];
$app->pipe(ExpressiveRedirectHandler\Middleware\RedirectHandlerAction::class);