Welcome Guest, Not a member yet? Register   Sign In
I need help with the CodeIgniter routes...
#1
Lightbulb 

Hello everyone,

I'm in the middle of some little problem here in a ecommerce that we are about to launch. The thing is that this ecommerce it's a new version of a older application that this client already have, and for the purpose of not losing the google adherence of the urls I need to accept this kind of url,

Code:
https://biocarers.com.br/index.php?id_menu=produto&id=92&titulo=Product-title-goes-here

and find the product page in the same way of the url

Code:
https://biocarers.com.br/produto/92/Product-title-goes-here


The are any chance of do this with CI routes? 'couse I've tried this and got no results... any ideias? ;/
The web is so cool! That you need to do cool stuff... Wink
Reply
#2

I believe CodeIgniter Routes are only useful when mapping from one CodeIgniter URL structure to another - not when working with different systems.

I suggest using Apache Mod Rewrite (or the equivalent for your webserver), which lets you use Regular Expressions to rewrite one URL structure to another. I'm not familiar enough to provide you the rules quickly, others may be more experienced.
Reply
#3

in routes:

PHP Code:
$route['produto/(:num)/(:any)'] = 'produto_controller/show/$1/$2'

in controller:

PHP Code:
public function show($id NULL$title NULL) {
  if(!empty($id)) {

  } elseif(!empty($this->input->get('id')) && !empty($this->input->get('title')) {

  }



Honestly though, you shouldn't need to search by the title if you have the ID.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB