承接 aw-studio/laravel-redirects 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aw-studio/laravel-redirects

Composer 安装命令:

composer require aw-studio/laravel-redirects

包简介

An easy solution to handle redirects in your Laravel application

README 文档

README

This package provides an easy way to create and manage redirects in your Laravel application.

Installation

Install the package via Composer:

composer require aw-studio/laravel-redirects

Publish the packages migrations and config:

php artisan vendor:publish --provider="AwStudio\Redirects\RedirectsServiceProvider"

Run the migration

php artisan migrate

Add AwStudio\Redirects\Middleware\RedirectRoutesMiddleware to /app/Http/Kernel.php:

class Kernel extends HttpKernel
{
    protected $middleware = [
        ...
        \AwStudio\Redirects\Middleware\RedirectRoutesMiddleware::class,
    ],
}

Usage

Using database redirects

The provided Redirect model stores the following attributes:

  • from_url
  • to_url
  • http_status_code (default 301)
  • active (default true)

With this you may create redirects like this:

app('redirect.model')->create([
    'from_url' => '/old',
    'to_url' => '/new',
    'http_status_code' => 301
]);

Using config redirects

If you need to configure some (static) redirects you may do so in the config/redirects.php.

'redirects' => [
    '/{any}' => '/en/{any}',
],

By default every redirect from the configuration file is handled as a 301. You may however overwrite it like this:

'redirects' => [
    '/old' => ['/temporary-new', 302],
],

Using URL parameters

Both, config and database redirects, support Laravel route parameters:

'redirects' => [
    '/blog/{post}' => '/news/{post}',
]

//

app('redirect.model')->create([
    'from_url' => 'blog/{post}',
    'to_url' => 'news/{post}',
]);

Credits

This package is inspired by and based on the discontinued Neurony/laravel-redirects package and also takes inspiration from spatie/laravel-missing-page-redirector.

统计信息

  • 总下载量: 4.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固