M. Ścieszka
M. Ścieszka

Reputation: 53

Codeigniter routing is not working

hello I need to route that

/tagi/fotografia,51/ to /galeria-sztuki-nowosci/?tags=51

this is only example ofc. My code in routes.php is :

$route['tagi/(:any),(\d+)'] = function($id) {
    return 'galeria-sztuki-nowosci/?tags=$id';
};

and it's not working.

Upvotes: 2

Views: 114

Answers (1)

M. Ścieszka
M. Ścieszka

Reputation: 53

First of all, Need to add comma in config.php

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-,';

next routes.php will be

$route["tagi/([a-z]+),(:any)"] ='old/galleryTags/$2';

And last need to do controller with

public function galleryTags($tags) {

    if ($tags == "_"): $tags = ""; endif;


    header("Location: /galeria-sztuki-nowosci/?tags=$tags");
}

done

Upvotes: 1

Related Questions