Skip to content

When redesigning an old site into a new one your URLs may change. If your old site URLs were popular you probably want to retain your SEO worth. One way of doing this is by providing permanent redirects from your old URLs to your new URLs.

License

Notifications You must be signed in to change notification settings

kmlpandey77/laravel-redirection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Redirection

This package design for redirects missing (404) URLs to new URLs.

When redesigning an old site into a new one your URLs may change. If your old site URLs were popular you probably want to retain your SEO worth. One way of doing this is by providing permanent redirects from your old URLs to your new URLs.

A package for handling redirects via database.

Example

From example.com/non-existing-page to example.com/existing-page

From example.com/old-page to example.com/new-page

From example.com/old/about-us to example.com/new/about-us

Installation

You can install the package via composer.

composer require kmlpandey77/laravel-redirection

The package will automatically register itself.

Next you must register the \Kmlpandey77\Redirection\Http\Middleware\Redirector middleware:

// app/Http/Kernel.php

protected $middleware = [
    ...
    \Kmlpandey77\Redirection\Http\Middleware\Redirector::class,
];

Publish the config file with:

php artisan vendor:publish --provider="Kmlpandey77\Redirection\RedirectionServiceProvider" --tag="config"

You can create the redirections table by running:

php artisan migrate

Usage

You just have to add an entry to the redirects links in the database by using example.com/admin/redirects. And you can change route link, prifix, and middleware in config

return [
    /**
     * By defult route is `admin`
     *
     */
    'prefix' => 'admin',

    /**
     * Defining middleware for route
     */

    'middleware' => [
        'web',
        // 'auth' // or admin
    ],

    /**
     *
     */
    'route_link' => 'redirects'
];

Changelog

Credits

License

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

About

When redesigning an old site into a new one your URLs may change. If your old site URLs were popular you probably want to retain your SEO worth. One way of doing this is by providing permanent redirects from your old URLs to your new URLs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published