【问题标题】:CodeIgniter Routing urls for Search term SEO friendly搜索词 SEO 友好的 CodeIgniter 路由 url
【发布时间】:2019-07-29 11:15:03
【问题描述】:

我有一个问题要让我的搜索网址对 SEO 更友好,并且 stackoverflow 中的解决方案都没有为我工作,我尝试了所有方法。

目前我的搜索网址是这样的: https://www.example.com/search?s=Cars&location=London,UK&lat=0.0000&lng=0.0000

我希望网址看起来像这样

https://www.example.com/find/Cars-London,UK/0.0000/0.0000

我的搜索类看起来像这样

class Search extends CI_Controller {    
    public function __construct() {
        parent::__construct();  
        check_installer();

        $this->load->helper('url','form');  
            $this->load->model('Home_Model');
            $this->load->model('Cars_Model');   
            $this->load->model('Search_Model');

            $this->load->dbforge();


    }   


    public function index(){    

        $this->load->view('config');
        if($this->input->post() )
        {
            echo  $this->load->view('search/tmpl/search_ajax','',true);
            die();
        }

        $data['meta_setup'] = "search";
        $this->load->view('search/search',$data);

    }

在路线上,无论我尝试过什么都行不通。我愿意接受任何使此网址对 SEO 友好的建议。

【问题讨论】:

  • 你的路线在哪里?
  • @Don'tPanic 在 routes.php 我有 $route['default_controller'] = 'Home';只有我试过 $route['search/(:any)'] = 'search/$1';但它没有用

标签: codeigniter


【解决方案1】:

您需要转到您的路由控制器 abd 手动将您的路由更改为您想要的特定 uri 这是一个如何创建用户友好 uri 的链接 链接:https://www.codeigniter.com/user_guide/general/routing.html

【讨论】:

  • 在 routes.php 我有 $route['default_controller'] = 'Home';只有我试过 $route['search/(:any)'] = 'search/$1';但它没有用
  • 我认为这可能有助于路由 :::: $route['edit/:id'] = 'contacts/edit';其中contact是控制器,edit是函数url ::: localhost/yourproject/contacts/edit/1 注意 :: 请记住您需要在函数参数中传递参数,例如: function edit($id){ //code } 您可以传递尽可能多的参数您喜欢的字段,如果您愿意,可以在以下位置查看示例:guru99.com/codeigniter-url-routing.html
猜你喜欢
  • 2011-12-24
  • 2012-10-06
  • 2011-11-21
  • 2016-05-28
  • 2011-04-06
  • 2015-07-30
  • 1970-01-01
  • 2012-01-17
  • 1970-01-01
相关资源
最近更新 更多