• Redirects

Redirects

Plugin information

by James Harley

Admin panel

This plugin adds the ability to create and manage redirects for your site helping maintain SEO value.

Support

#redirects on Discord

Views

3194

License

Custom

Documentation

Usage

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.

Screenshot 2022-04-22 at 11 51 44

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.

Screenshot 2022-04-22 at 11 52 53

Wildcards

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.

Screenshot 2022-12-31 at 14 19 38

Hits

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,
];

Widgets

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,
];

Support

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].