【问题标题】:.php in a routes path for Laravel 5.5.php 在 Laravel 5.5 的路由路径中
【发布时间】:2018-06-18 19:03:51
【问题描述】:

我正在将一个站点从一个普通的 PHP 站点迁移到 Laravel。有没有办法包含旧的 URL 路径 /products.php?id=1 以匹配 routes.php 中的路由?

我希望能够将它们重定向到正确的 URL,提取 id 变量并重组 URL 以匹配新路由。

【问题讨论】:

  • Alexey 有一个很好的答案,但您也可以在网络服务器级别执行此操作(例如,如果您使用的是 Apache,则为.htaccess)。
  • 根据您要重定向的 URL 数量,您可能需要查看 Spatie's missing page redirector package

标签: php laravel laravel-5


【解决方案1】:

使用.php 创建路由:

Route::get('products.php', 'ProductController@index');

并使用它:

public function index()
{
    $id = request('id');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-05
    • 2018-06-23
    • 2019-04-02
    • 2018-03-01
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多