.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:

  1. you submit following url: www.mysite.com/temporary/articles.php/artid=1
  2. ci catches , reroutes such: in routes.php:

    $route['temporary/articles.php/artid=(:any)'] = "temporary/articles/search_by_id/$1"; 
  3. 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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -