black-bits/laravel-seo-rewrite

A clean and easy to use package to create seo rewrites using events.

1.0.0 2018-07-25 21:14 UTC

This package is auto-updated.

Last update: 2024-03-29 03:57:45 UTC


README

Latest Version on Packagist Total Downloads

Introduction

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.

Installation

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.

Usage

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.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email hello@blackbits.io instead of using the issue tracker.

Credits

Support us

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.

License

The MIT License (MIT). Please see License File for more information.