如何在codeigniter中重定向旧的php路由

如何在codeigniter中重定向旧的php路由,codeigniter,redirect,routes,Codeigniter,Redirect,Routes,我有旧的url,现在在我的项目中,url将是 如何在routes.php中制定重定向规则? 谢谢您不需要对routes.php进行任何更改,只需创建一个控制器“Product”,其中一个方法是“ver”,它接收231(我猜是id)作为参数,如下所示: defined('BASEPATH') OR exit('No direct script access allowed'); class Product extends CI_Controller { public function

我有旧的url,现在在我的项目中,url将是

如何在routes.php中制定重定向规则?
谢谢

您不需要对
routes.php进行任何更改,只需创建一个控制器“Product”,其中一个方法是“ver”,它接收231(我猜是id)作为参数,如下所示:

defined('BASEPATH') OR exit('No direct script access allowed');

class Product extends CI_Controller {

    public function __construct(){
        parent::__construct();
    }

    public function ver($id) {
        // do your things
    }

我希望它能有所帮助。

您可能需要在config/routes.php中设置路由

$route['product/ver/(:num)'] = 'product/ver/$1';
http://example.com/index.php/products/ver/231

然后控制器

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Product extends CI_Controller {

public function __construct(){
    parent::__construct();
}

public function ver($id) {
    /*
       echo $id;
    */
}

您在哪里有旧的URL?现在还不清楚你的问题是什么。是的,我的旧网页有300多个url,我的新网页有,所以我在谷歌搜索错误404当clic对旧的url。在我的项目中,我有一个控制器产品与ver($id)功能,但如果我clic在不显示我的正确的产品231尝试类似的东西吗?example.com/product/ver/231我尝试了一下,但因为我还有公共函数index()来显示所有产品:example.com/products我总是会得到所有产品的列表。不是产品231或类似的页面