skip to Main Content

How to make my codigniter url seo friendly.

this is my url

http://localhost/picker2/web/search?category=doctor

i want url like this

http://localhost/picker2/web/search/doctor/

3

Answers


  1. read this article http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html

    to create url like this : http://heloo.com/article/codeigniter-based-url
    add this code in routes.php

    $route['article/(:any)'] = "article/readmore/$1";
    

    description :

    1. article : class name
    2. readmore : method from class article
    3. $1 : get value from uri segment 2 value
    Login or Signup to reply.
  2. Actually you have two options

    1) Using Routes (this one already denyptw discussed right ?)

    2) use the URL Helper url_title function

    Note : You can use Parameter instead of query string

    http://localhost/picker2/web/search?category=doctor

    http://localhost/picker2/web/search/doctor/

    web controller , search function , doctor parameter

    example :

    class Web extends CI_Controller
    {
    
    public function search($value)
    {
    
      //use this $value in your searching logic 
    
    }
    
    
    
    }
    

    You need Example of URL Helper

    check this link Codeigniter URL: How to display id and article title in the URL

    Login or Signup to reply.
    1. you can do this using routes.(Elislab)
    2. as a simple trick.(Using Controllers)

      • each and every page create a controller. (ex: if contact create contact controller, if product create product controller.) So each and every link will be look like(if you click product) www.example.com/product,(if you click contact) www.example.com/contact.

      • If you want something to do with your product then write that method inside the product controller.(ex if you create cart then URL show www.example.com/product/cart )

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search