How to use Routing in the PHP CodeIgniter framework?
Please follow the steps:
- Sometimes in your code, the function names include the character underscore. And, thus it becomes a part of the URL.
- But an underscore in URL, isn’t so good for search engine optimization.
- It is therefore advisable, to replace the underscores with hyphens.
- Thankfully, this can be done so easily in CodeIgniter.
- Click open the routes.php file, inside the config folder.
- Scroll down the page, and type TRUE.
- Now, access the same page with hyphens.
- It works.
- All files with underscores have been replaced by hyphens.
- You can replace complete words in this way.
- Open the routes.php file again.
Since the URL contains a query string variable, you need to type some extra codes, after the filename.
- Now check.
The same page is resolved by a different filename.
- This way you can change the display URL of any webpage.
- This enhances the basic security level of your website, by hiding the actual controller names.