1. Go to this page and download the library: Download asignua/filament-redirects 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/ */
asignua / filament-redirects example snippets
use Asignua\FilamentRedirects\RedirectsPlugin;
$panel->plugin(RedirectsPlugin::make()
->authorize(fn (): bool => auth()->user()?->isAdmin()));
use Asignua\FilamentRedirects\Redirects;
use Illuminate\Foundation\Configuration\Middleware;
->withMiddleware(function (Middleware $middleware): void {
Redirects::appendTo($middleware);
})
'ignore' => ['wp-*', '*/wp-*', '*.php', '.env*', '.git/*', '*.png', '*.map', /* ... */], // wildcards, case-insensitive
'ignore_user_agents' => ['*semrushbot*'],
'ignore_bots' => false, // off on purpose: a Googlebot request for a dead URL is what you want to see
use Asignua\FilamentRedirects\Enums\RedirectCode;
use Asignua\FilamentRedirects\Redirects;
Redirects::create('old/page', 'new/page'); // 301, default language
Redirects::create('old/page', 'new/page', 302, 'en'); // 302 for the `en` row
Redirects::create('old/page', 'https://other.site/x', RedirectCode::PermanentKeepMethod);
Redirects::create('retired', '', RedirectCode::Gone); // answer with the error page (410)
Redirects::create('old/page', 'new/page', entity: $post); // remember what it leads to
RedirectsPlugin::make()
->authorize(fn (): bool => auth()->user()?->isAdmin())
->navigationGroup('SEO')
->navigationSort(30)
->navigationIcon('heroicon-o-arrows-right-left')
->redirects() // or ->redirects(false) to hide the resource
->notFoundLog(); // or ->notFoundLog(false)