by James Harley
This plugin adds the ability to create and manage redirects for your site helping maintain SEO value.
Register the middleware within the $middleware
array inside of App/Http/Kernel.php
protected $middleware = [ // ... \JKHarley\FilamentRedirects\Middleware\RedirectMiddleware::class,];
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-redirects-migrations"php artisan migrate
Once setup you should now see a new redirects
resource.
You can create new redirects from within the new redirects
resource and add a specified status code with the option to enable or disable the redirect.
You can add wildcards to the end of your url paths. For example setting a source of /blogs/*
and a destination of /articles/*
would allow requests for /blogs/10
to be redirected to /articles/10
.
You can see the number of times a redirect has been hit from the hits
column in the redirects table. By default, the redirects will record all hits and disallow the users browser from caching the redirect. However, you can change this behaviour by setting the record_all_hits
key in the filament-redirects.php
config file to false
. This will only record the first hit and allow the browser to cache the redirect.
php artisan vendor:publish --tag="filament-redirects-config"
// config/filament-redirects.php <?php return [ 'record_all_hits' => false,];
By default you will see a stats widget which shows Total Redirects
, Active Redirects
and Inactive Redirects
. If you would like to hide the widget you can set the show_stats_widget
key in the filament-redirects.php
config file to false
.
If not yet published, publish the config file with:
php artisan vendor:publish --tag="filament-redirects-config"
Then set the show_stats_widget
key to false.
// config/filament-redirects.php <?php return [ 'record_all_hits' => true, 'show_stats_widget' => false,];
If you have a request, question or have spotted an issue, you can either send a message into the #redirects
discord channel or email me at [email protected].