Php CodeIgniter自定义URI路由
我想在CodeIgniter上创建定制的permalinks,实际上我买了这个脚本,但是开发人员因为一些漠不关心而离开了那个项目。所以现在的问题是,我不知道如何更改该脚本上的永久链接。permalinks的主要问题是,当我在搜索栏上搜索任何内容时,我会得到以下url: domain.com/?s=xxxxx%20YYYY 相反,我希望此url结构: domain.com/search/xxxxxx-yyyy/ application/config/routes.phpPhp CodeIgniter自定义URI路由,php,codeigniter,url,permalinks,Php,Codeigniter,Url,Permalinks,我想在CodeIgniter上创建定制的permalinks,实际上我买了这个脚本,但是开发人员因为一些漠不关心而离开了那个项目。所以现在的问题是,我不知道如何更改该脚本上的永久链接。permalinks的主要问题是,当我在搜索栏上搜索任何内容时,我会得到以下url: domain.com/?s=xxxxx%20YYYY 相反,我希望此url结构: domain.com/search/xxxxxx-yyyy/ application/config/routes.php 我想你的要求是不可能直接实
我想你的要求是不可能直接实现的。 假设你的状态是
<form action="" method="GET">
<input type="text" name="s" value="" placeholder="Search music..." />
</form>
您必须将$route变量放在route.php文件中,而不是config.phpCan文件中,您可以向我们显示您的搜索表单吗??
<form action="" method="GET">
<input type="text" name="s" value="" placeholder="Search music..." />
</form>
<?php
class Music extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('xyz_model');
}
public function index()
{
if($this->input->get('s'))
{
$s = $this->input->get('s');
redirect('/search/'$s);
}
$this->load->view('home.php');
}
public function search()
{
$s = $this->uri->segment(2);
/*
Now you got your search parameter.
Search in your models and display the results.
*/
$data['search_results'] = $this->xyz_model->get_search($s);
$this->load->view('search_results.php', $data);
}
}