kmlpandey77 / laravel-redirection
此包旨在将404页面重定向到新的链接
v1.0.4
2021-02-07 12:55 UTC
README
此包旨在将丢失的(404)URL重定向到新的URL。
当将旧网站重新设计为新网站时,您的URL可能会更改。如果您的旧网站URL很受欢迎,您可能希望保留您的SEO价值。实现这一目标的一种方法是通过从旧URL永久重定向到新URL。
一个用于通过数据库处理重定向的包。
示例
从 example.com/non-existing-page
到 example.com/existing-page
从 example.com/old-page
到 example.com/new-page
从 example.com/old/about-us
到 example.com/new/about-us
安装
您可以通过composer安装此包。
composer require kmlpandey77/laravel-redirection
此包将自动注册自己。
接下来,您必须注册 \Kmlpandey77\Redirection\Http\Middleware\Redirector
中间件
// app/Http/Kernel.php protected $middleware = [ ... \Kmlpandey77\Redirection\Http\Middleware\Redirector::class, ];
使用以下命令发布配置文件
php artisan vendor:publish --provider="Kmlpandey77\Redirection\RedirectionServiceProvider" --tag="config"
您可以通过运行以下命令创建 redirections
表
php artisan migrate
使用
您只需在数据库中使用 example.com/admin/redirects
添加重定向链接的条目。您还可以在配置中更改路由链接、前缀和中间件
return [ /** * By defult route is `admin` * */ 'prefix' => 'admin', /** * Defining middleware for route */ 'middleware' => [ 'web', // 'auth' // or admin ], /** * */ 'route_link' => 'redirects' ];
变更日志
鸣谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。