GithubHelp home page GithubHelp logo

kmlpandey77 / laravel-redirection Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 16 KB

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: MIT License

PHP 79.40% Blade 20.60%
laravel-redirect

laravel-redirection's Introduction

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.

laravel-redirection's People

Contributors

kmlpandey77 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.