skip to Main Content

I’m building an online store based on CodeIgniter. I’d like URLs to look like this? What is the solution for this type of SEO friendly url.

http://example.com/[product-category]/[product-sub category]

I need this url:

example.com/women/sarees-sari

But my url is generated

example.com/Product/item/MQ==/women/sarees-sari

/Product/ is my controller,
/item/ is function name,
/MQ==/ is my product id

2

Answers


  1. You can use routing to handle your request url. It’s simple. For example for your case:

    $route['women/sarees-sari'] = 'Product/item/MQ==';
    

    Codeigniter has _remap function that can be called on controllers. So you can call this on core controller or main controller, and call your function that wish.

    Login or Signup to reply.
  2. CodeIgniter has very good routing System so you can modify your url as per your requirement and linking using /application/config/routes.php file.

    If you open this file first time, you will see only default controller, i.e $route[‘default_controller’] = ‘welcome’;
    but you can add as many routes as you want. Like in your case for seo, you should add
    $route[‘women-sarees-sari’] = ‘Product/item/MQ==’; and this will route the user from http://www.example.com/women-sarees-sari to correct controller and method.

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