How to use Routing in the PHP CodeIgniter framework?

Please follow the steps:

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



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store