SlideShare a Scribd company logo
CodeIgniter
    Custom Routing : Manipulate your URI




                               Abdul Malik Ikhsan
   http://slideshare.net/samsonasik/presentations
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
Why ?
   SEO Mith 
   Hide Original action controller
   Manage which action will be called
   URI Simplicity
    ….like this ……
     http://twitter.com/samsonasik
Default Routing


  example.com/product/detail/1
  example.com/product/detail/2
  example.com/product/detail/3
How to Change ?
 Modify route in config routes
 _remap in your controller ( modify
  from action controller only )
Modify route in config routes
////////////////custom route///////////////

$route['product/(:num)'] = "product/detail/$1";
$route['product/(:num)/get'] ="product/checkout/$1";
$route['product/(:any)'] = "product/index";
$route['blog/(:any)'] = "blogs/users/$1“;
$route[‘hehehe'] = "blogs/index“;

/* End of file routes.php */
/* Location: ./application/config/routes.php */
URI Result
 Example.com/product/15
 Exampleblog.com/blog/samsonasik
_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;
 }
And one more thing ….


      Remove your
  index.php from your
   URI with .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Thank You ;)
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

More Related Content

PPTX
How to Use Open Source Intelligence (OSINT) in Investigations
PPTX
Digital Forensics best practices with the use of open source tools and admiss...
PDF
OSINT with Practical: Real Life Examples
PPT
Security and personnel bp11521
PDF
NcN2015. Técnicas OSINT para investigadores de seguridad.
PPTX
Osint {open source intelligence }
PDF
Data Processing - data privacy and sensitive data
How to Use Open Source Intelligence (OSINT) in Investigations
Digital Forensics best practices with the use of open source tools and admiss...
OSINT with Practical: Real Life Examples
Security and personnel bp11521
NcN2015. Técnicas OSINT para investigadores de seguridad.
Osint {open source intelligence }
Data Processing - data privacy and sensitive data

What's hot (20)

PPT
Computer Security and safety
PPTX
Introduction to Network Security
PPTX
Data Loss Prevention
PPTX
Awareness Training on Information Security
PPTX
E mail Investigation
DOCX
Security and Compliance In Microsoft Office 365 Whitepaper
PPT
Information Security
PPTX
IT Security DOs and DON'Ts
PPTX
Computer forensics powerpoint presentation
PPT
Information Assurance And Security - Chapter 2 - Lesson 2
PPTX
Information Security Awareness, Petronas Marketing Sudan
PPT
computer forensics
PPTX
Privacy & Data Protection
PDF
SEGURIDAD INFORMATICA
PPT
Cyber forensics
PPTX
Physical Security In The Workplace
PPT
How to install windows 10
PPTX
Multifactor Authentication
DOC
Internet theory and practical
PPTX
Tools for Open Source Intelligence (OSINT)
Computer Security and safety
Introduction to Network Security
Data Loss Prevention
Awareness Training on Information Security
E mail Investigation
Security and Compliance In Microsoft Office 365 Whitepaper
Information Security
IT Security DOs and DON'Ts
Computer forensics powerpoint presentation
Information Assurance And Security - Chapter 2 - Lesson 2
Information Security Awareness, Petronas Marketing Sudan
computer forensics
Privacy & Data Protection
SEGURIDAD INFORMATICA
Cyber forensics
Physical Security In The Workplace
How to install windows 10
Multifactor Authentication
Internet theory and practical
Tools for Open Source Intelligence (OSINT)
Ad

Viewers also liked (9)

PDF
Codeigniter : the security and the magic of hook
PDF
Code igniter parameter passing techniques
PPTX
I Love codeigniter, You?
KEY
Theme API
PDF
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
PDF
Add edit delete in Codeigniter in PHP
PDF
Introduce to Linux command line
PDF
Dynamic Linker
PDF
Rootkit 101
Codeigniter : the security and the magic of hook
Code igniter parameter passing techniques
I Love codeigniter, You?
Theme API
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
Add edit delete in Codeigniter in PHP
Introduce to Linux command line
Dynamic Linker
Rootkit 101
Ad

Similar to Codeigniter : Custom Routing - Manipulate Uri (20)

PPTX
Magento Live Australia 2016: Request Flow
PDF
Introduction to angular js
ODP
CodeIgniter PHP MVC Framework
PDF
Rails 3 overview
ODP
Pyramid Lighter/Faster/Better web apps
PDF
The Rails Way
PDF
Silex Cheat Sheet
PDF
Silex Cheat Sheet
PDF
Django Vs Rails
PDF
I Phone On Rails
PDF
Desymfony 2011 - Habemus Bundles
PPT
Nashvile Symfony Routes Presentation
PPTX
Optimizing Angular Performance in Enterprise Single Page Apps
PDF
Unit testing after Zend Framework 1.8
PDF
Rails 3: Dashing to the Finish
PDF
Spring Mvc Rest
PDF
Perl web frameworks
PDF
Curscatalyst
PPTX
Angular Workshop_Sarajevo2
PDF
Doctrine For Beginners
Magento Live Australia 2016: Request Flow
Introduction to angular js
CodeIgniter PHP MVC Framework
Rails 3 overview
Pyramid Lighter/Faster/Better web apps
The Rails Way
Silex Cheat Sheet
Silex Cheat Sheet
Django Vs Rails
I Phone On Rails
Desymfony 2011 - Habemus Bundles
Nashvile Symfony Routes Presentation
Optimizing Angular Performance in Enterprise Single Page Apps
Unit testing after Zend Framework 1.8
Rails 3: Dashing to the Finish
Spring Mvc Rest
Perl web frameworks
Curscatalyst
Angular Workshop_Sarajevo2
Doctrine For Beginners

More from Abdul Malik Ikhsan (6)

PDF
Zend Framework 2 : Dependency Injection
PDF
Codeigniter : Using Third Party Components - Zend Framework Components
PDF
Codeigniter : Two Step View - Concept Implementation
PDF
Codeigniter : The Introduction
PDF
Application framework
PDF
Software architectural pattern - MVC
Zend Framework 2 : Dependency Injection
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Two Step View - Concept Implementation
Codeigniter : The Introduction
Application framework
Software architectural pattern - MVC

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Machine learning based COVID-19 study performance prediction
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
Machine Learning_overview_presentation.pptx
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MYSQL Presentation for SQL database connectivity
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
Assigned Numbers - 2025 - Bluetooth® Document
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25-Week II
Machine learning based COVID-19 study performance prediction
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf

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
  • 4. Default Routing  example.com/product/detail/1  example.com/product/detail/2  example.com/product/detail/3
  • 5. How to Change ?  Modify route in config routes  _remap in your controller ( modify from action controller only )
  • 6. Modify route in config routes ////////////////custom route/////////////// $route['product/(:num)'] = "product/detail/$1"; $route['product/(:num)/get'] ="product/checkout/$1"; $route['product/(:any)'] = "product/index"; $route['blog/(:any)'] = "blogs/users/$1“; $route[‘hehehe'] = "blogs/index“; /* End of file routes.php */ /* Location: ./application/config/routes.php */
  • 7. URI Result  Example.com/product/15  Exampleblog.com/blog/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
  • 10. RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
  • 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