How to Troubleshoot Apps for the Modern Connected Worker
Codeigniter : Custom Routing - Manipulate Uri
1. CodeIgniter
Custom Routing : Manipulate your URI
Abdul Malik Ikhsan
http://slideshare.net/samsonasik/presentations
2. Introduction : URI vs URL
URI : Content type is given by http
content negotiation
ex : http://www.w3.org/Icons/w3c_home
~> content type : PNG
URL : Content type is represent by
spesific resource in web address
ex :
http://www.w3.org/Icons/w3c_home.gif
3. Why ?
SEO Mith
Hide Original action controller
Manage which action will be called
URI Simplicity
….like this ……
http://twitter.com/samsonasik
8. _remap in controller
public function _remap($method, $params = array())
{
if (method_exists($this, str_replace('-','_',$method) )) {
call_user_func_array(array($this, str_replace('-','_', $method) ), $params);
} else{
show_404();
}
}
public function show_news($id) //will be called show-news/$id
{
echo 'show news'.$id;
}
public function comment_news($id) //will be called comment-news/$id
{
echo 'comment news'.$id;
}
9. And one more thing ….
Remove your
index.php from your
URI with .htaccess
12. This presentation contained copyrighted material licensed
under various creative commons licenses unless otherwise
noted:
References and Further Reading
http://www.anmsaiful.net/blog/php/codeigniter-remap-power-benefit.html
http://en.wikipedia.org/wiki/Content_negotiation
http://ajaxprojects.com/ajax/newsdetails.php?itemid=55
http://www.pierobon.org/iis/url.htm
CodeIgniter User Guide
Photos
http://media.popularmechanics.com/images/coaster-maverick-0708.jpg