Manage Application Redirects with the Laravel Redirection Package

iwano@_84

Laravel Redirection is a Laravel +8 package to manage URL redirections inside your Laravel application. It’s capable of using different data sources to store redirects and allows better SEO support for your application.

The Redirection package supports a config and database driver out of the box, and you can create a custom driver to fit your needs. You could provide a UI to add and manage redirects for your applications using the database driver, for example.

If you need to enhance the model provided by this package, you can extend the package’s model and configure the package to use the extended model:

1namespace App\Models;

2 

3use SiroDiaz\Redirection\Models\Redirection;

4 

5class Redirect extends Redirection

6

7 /* ... */

8

To get started with this package, you can use the config driver to test and add redirects to the published config quickly:

1return [

2 // ...

3 'urls' => [

4 '/old/url' => '/new/url',

5 '/another/old/url' => '/another/new/url',

6 '/url/with?id=123' => '/url/with/123',

7 ],

8];

You can also specify which type of redirect status code a match should use:

1return [

2 'urls' => [

3 '/old/url' => ['new_url' => '/new/url', 'status_code' => 302],

4 '/another/old/url' => '/another/new/url',

5 '/url/with?id=123' => ['new_url' => '/url/with/123'],

6 ],

7];

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Next Post

Contrast Stability Introduces Cloud-Indigenous Automation

New integrations permit Contrast capabilities to be shipped to Red Hat OpenShift consumers LOS ALTOS, Calif., April 22, 2022 /PRNewswire/ — Contrast Stability (Distinction), the leader in code protection that empowers developers to protected-as-they code, currently introduced the introduction of cloud-indigenous automation for users leveraging Purple Hat OpenShift, the industry’s […]

Subscribe US Now