Book Image

CodeIgniter Web Application Blueprints

Book Image

CodeIgniter Web Application Blueprints

Overview of this book

Table of Contents (16 chapters)
CodeIgniter Web Application Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adjusting the routes.php file


We want short URLs—in fact the shorter the better. The user clicking on a URL would be better served if the URL were as short as possible; for that reason, it would be a good idea if we removed certain things from the URL to make it shorter—for example, the controller name and function name. We will use CodeIgniter's routing functionality to achieve this. This can be done as follows:

  1. Open the config/routes.php file for editing and find the following lines (near the bottom of the file):

    $route['default_controller'] = "welcome";
    $route['404_override'] = '';
  2. Firstly, we need to change the default controller. Initially, in a CodeIgniter application, the default controller is set to welcome. However, we don't need that; instead we want the default controller to be create. So, consider the following line:

    $route['default_controller'] = "welcome";

    Replace it with the following code:

    $route['default_controller'] = "create";
  3. We will also need to set up a route rule for the...