Ritesh Paliwal
Ritesh Paliwal

Reputation: 3

Route in CodeIgniter

I am creating e-commerce website in CodeIgniter and I Have to prepare SEO friendly URL.

Currently My URL is:-

abc.com/product/product_list/1/categoryName

And I have to make like this:-

abc.com/categoryName

I have to remove controller name as well as function name and one uri segment i.e., category id and show only category name.

How can I do this? Is this possible using .htaccess file?

Upvotes: 0

Views: 267

Answers (1)

devpro
devpro

Reputation: 16117

You can use route as:

$route["(:any)"] = "product/product_list/$1";

But issue is that it will hurt your other controllers like if you have page like

abc.com/contactus

It will call the product/product_list/. I suggest you to use route as:

$route["category/(:any)"] = "product/product_list/$1";

You can use URL like:

abc.com/category/yourCatName

And get category name in controller by using CI Segments.

CI Routes

Upvotes: 1

Related Questions