CodeIgniter Forums
How to add .php extension to Codeigniter 2.x controller URL's - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: How to add .php extension to Codeigniter 2.x controller URL's (/showthread.php?tid=83446)



How to add .php extension to Codeigniter 2.x controller URL's - NorahDaniels - 09-27-2022

I am using Codeigniter 2.x for a project and have limited knowledge on .htaccess etc.

I've created an RESTful api which can be accessed via "api" controller's "getfeedback" function and was able to remove the index.php from the URL using .htaccess rules.

Example That currently works (without .php extension):

www.example.com/api/getfeedback?param=abc&param2=defghi

The team I created the api for asked if I can create something which has the .php extension in the urls for some reason they can't use it without the extension. I am able to achieve this if I create a pure php file outside of my codeigniter project directory, however I would like to use codeigniter framework to keep everything consistent. Basically I am looking for a way to have the URL be accessed via

Looking for:

www.example.com/api/getfeedback.php?param=abc&param2=defghi

How can I achieve this? Is there some kind of configuration that would allow both methods to work? Any help is greatly appreciated.