internetguru/laravel-smart-redirect 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

internetguru/laravel-smart-redirect

Composer 安装命令:

composer require internetguru/laravel-smart-redirect

包简介

A configurable Laravel 11 middleware package that handles URL redirection based on defined routes and uses Levenshtein distance to find the closest matching route for 404 errors.

README 文档

README

A configurable Laravel 11 middleware package that handles URL redirection based on defined routes and uses Levenshtein distance to find the closest matching route for 404 errors.

Features

  • Redirect URLs based on predefined rules
  • Automatically find the closest matching route using Levenshtein distance
  • Easily configurable parameters for route combinations

Installation

  1. Require the package via Composer:

    composer require internetguru/laravel-smart-redirect
  2. Publish the configuration file:

    php artisan vendor:publish --provider="Internetguru\\SmartRedirect\\SmartRedirectServiceProvider" --tag="config"
  3. Register the service provider (if not auto-discovered) in config/app.php:

    'providers' => [
        // Other Service Providers
        Internetguru\SmartRedirect\SmartRedirectServiceProvider::class,
    ],

Configuration

After publishing the configuration file, you can configure your redirects and parameters in config/smart-redirect.php.

return [
    'redirects' => [
        // '/old-path' => '/new-path',
    ],
    'params' => [
        // 'locale' => ['en', 'cs'],
        // 'location' => ['racineves', 'kralupy'],
    ],
];

Usage

To always use the middleware, add it to app/Http/Kernel.php:

protected $middlewareGroups = [
    'web' => [
        // Other Middleware
        \Internetguru\SmartRedirect\Middleware\Redirect::class,
    ],
];

You can also use the middleware only for some of the routes. Register the middleware in app/Http/Kernel.php:

protected $routeMiddleware = [
    'smart-redirect' => \Internetguru\SmartRedirect\Middleware\Redirect::class,
];

And then use it in your routes, e.g. in routes/web.php:

Route::get('/old-path', function () {
    return 'This is the old path.';
})->middleware('smart-redirect');

Example

Let's say you have a website with the following routes:

  • /
  • /about
  • /contact
  • /services
  • /services/web-development
  • /services/mobile-development
  • /services/seo

And you want to redirect the following URLs:

  • /web-dev to /services/web-development
  • /mobile-dev to /services/mobile-development
  • /seo to /services/seo

You can define the redirects in config/smart-redirect.php:

'redirects' => [
    '/web-dev' => '/services/web-development',
    '/mobile-dev' => '/services/mobile-development',
    '/seo' => '/services/seo',
],

Now, when you visit /web-dev, you will be redirected to /services/web-development.

If you visit a non-existing URL, e.g. /web, the middleware will automatically find the closest matching route and redirect you to the correct one.

License & Commercial Terms

License

Copyright © 2026 Internet Guru

This software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.

Disclaimer: This software is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability.

Commercial Use

The standard CC BY-NC-SA license prohibits commercial use. If you wish to use this software in a commercial environment or product, we offer flexible commercial licenses tailored to:

  • Your company size.
  • The nature of your project.
  • Your specific integration needs.

Note: In many instances (especially for startups or small-scale tools), this may result in no fees being charged at all. Please contact us to obtain written permission or a commercial agreement.

Contact for Licensing: info@internetguru.io

Professional Services

Are you looking to get the most out of this project? We are available for:

  • Custom Development: Tailoring the software to your specific requirements.
  • Integration & Support: Helping your team implement and maintain the solution.
  • Training & Workshops: Seminars and hands-on workshops for your developers.

Reach out to us at info@internetguru.io — we are more than happy to assist you!

internetguru/laravel-smart-redirect 适用场景与选型建议

internetguru/laravel-smart-redirect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.28k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 internetguru/laravel-smart-redirect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 internetguru/laravel-smart-redirect 我们能提供哪些服务?
定制开发 / 二次开发

基于 internetguru/laravel-smart-redirect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-31