我有http://example.com/products.php?s_productid=231之类的旧网址,现在我的proyect网址将是http://example.com/products/ver/231
如何在routes.php中制定规则以重定向? 感谢
答案 0 :(得分:0)
你不需要在routes.php
做任何改变,你只需要创建一个控制器“产品”,一个方法“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
}
我希望它有所帮助。
答案 1 :(得分:0)
您可能需要在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;
*/
}