user1739460
user1739460

Reputation: 165

Codeigniter RewriteRule for controller

I have this url: http://domain.any/enfermedades_dermatologicas/term/181

I would like to skip the name of the method "term" so the result be something like this http://domain.any/enfermedades_dermatologicas/181

I tried with the following rewrite rules but it's not working:

RewriteRule ^enfermedades_dermatologicas/(.+) /enfermedades_dermatologicas/term/$1
RewriteRule ^enfermedades_dermatologicas/(.+) /index.php/enfermedades_dermatologicas/term/$1

The controller function structure is the following:

public function term( $id_contenido ){ ... }

Please any help would be apreciated, sorry for my survival english.

Upvotes: 0

Views: 106

Answers (1)

jleft
jleft

Reputation: 3457

Rather than using .htaccess, you could use the following route:

$route['enfermedades_dermatologicas/(:num)'] = 'enfermedades_dermatologicas/term/$1';

This route will map a URL with 'enfermedades_dermatologicas' as the first segment and any number as the second segment, to the enfermedades_dermatologicas controller and the term function within that controller, with the number in the URL as the function's parameter.

Upvotes: 1

Related Questions