.htaccess - Change Dynamic Url using htaccess in codeigniter -
i have following url structure: www.mysite.com/temporary/articles.php/artid=1
i change with: www.mysite.com/temporary/articles/article-title-here.
where article-title should based on artid . can tell me how can that?
no .htaccess needed. create controller method , add routes. use following approach:
- you submit following url:
www.mysite.com/temporary/articles.php/artid=1
ci catches , reroutes such: in routes.php:
$route['temporary/articles.php/artid=(:any)'] = "temporary/articles/search_by_id/$1";
in controller:
class articles extends ci_controller { public function index($title){ //load model //from model, query database article info title //send results view. } public function search_by_id($id){ //load model //from model, query database article title id. set = $title redirect("temporary/articles/$title") } }
Comments
Post a Comment