With this package we want to give you a simple way to manage your SEO rewrites in your Laravel application. Rewrites are created and deleted by dispatching events in your code.
You can install the package via composer.
composer require black-bits/laravel-seo-rewrite
Next you need to run our migrations.
php artisan migrate
When you install the package our LaravelSeoRewrites Middleware is automatically pushed to the global MiddlewareGroup and activated.
To create a new redirect, simply create a new SeoRewrite entry.
- The source value must be a relative path matching one of your routes.
- The destination can be any relative or absolute URL.
- The type must be a valid redirect type (permanent, temporary, etc.)
SeoRewrite::create([
'source' => '/old-route',
'destination' => '/new-route',
'type' => 301
]);
SeoRewrite::create([
'source' => '/old-route',
'destination' => 'https://your-new.domain/old-route',
'type' => 308
]);
We run a basic redirect loop detection on model save, but not all cases can be detected. Please be aware that you can potentially create loops.
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email hello@blackbits.io instead of using the issue tracker.
Black Bits, Inc. is a web and consulting agency specialized in Laravel and AWS based in Grants Pass, Oregon. You'll find an overview of what we do on our website.
The MIT License (MIT). Please see License File for more information.