gpt4 book ai didi

php - codeigniter 路由任何或 num 不工作

转载 作者:可可西里 更新时间:2023-11-01 01:00:54 24 4
gpt4 key购买 nike

我有这样的 url http://lp.dev/sisters/adab/1 但是当我使用 (:num)(:any) 获取值 1 因为路由给我 404 页面

路线如下

$route['default_controller'] = "frontend/home";
$route["sisters/adab/(:num)"] = "frontend/pages/$1"; //<-- this is my issue
$route['404_override'] = 'errors/error_404';

Controller :前端文件夹内的 pages.php

class Pages extends CI_Controller {
function __construct() {
parent::__construct();

$this->name = $this->uri->segment(2);
}

public function index($variable = NULL)
{
dd($variable);

if(is_page($this->name))
load_view("$this->name/home");
else
load_view('errors/error_404');
}
}

最佳答案

我猜你想要这个

$route["sisters/adab/(:num)"] = "frontend/pages/index/$1"; //correct

$route["sisters/adab/(:num)"] = "frontend/pages/$1"; // is wrong because
//it is redirecting to your page's controller and looking for a method (:num)

关于php - codeigniter 路由任何或 num 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27218488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com