Reputation: 3
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
product
is my controllerproduct_list
is my function name1
= category idcategoryName
is my category NameAnd 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
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
.
Upvotes: 1