CodeIgniter Forums
Removing .php extension gives 404 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Removing .php extension gives 404 (/showthread.php?tid=80958)



Removing .php extension gives 404 - sj2022 - 01-07-2022

Hi, I have integrated a CMS (simplece) which is built based on CodeIgniter (version 3x). When I integrate the code into a page (i.e., including the php code on the top of the page), then removing .php extension returns 404 error! I have tried all different redirecting and rewriting tricks in .htaccess, but no success! Helps are much appreciated.


RE: Removing .php extension gives 404 - sj2022 - 01-08-2022

(01-07-2022, 05:51 AM)sj2022 Wrote: Hi, I have integrated a CMS (simplece) which is built based on CodeIgniter (version 3x). When I integrate the code into a page (i.e., including the php code on the top of the page), then removing .php extension returns 404 error! I have tried all different redirecting and rewriting tricks in .htaccess, but no success! Helps are much appreciated.

I should add one thing: if I would set $config['enable_query_strings'] = TRUE; then the code works, with extension-free URL, but the other functionalities of the main code (CodeIgniter) stop working!


RE: Removing .php extension gives 404 - includebeer - 01-09-2022

Since this is a paid product, maybe you should first try asking them?


RE: Removing .php extension gives 404 - sj2022 - 01-10-2022

Thanks includebeer, but it shouldn't do anything with that product (I have anyhow asked them -- no response). The conflict arrises from the $config['enable_query_strings']. If this is set 'TRUE' then the https://example.com/file is shown correctly (file is actually file.php; the extension has been removed with .htaccess), but then the 'string' url (e.g., https://example.com/simplece/content/text/4?return_url=https%3A%....; I have removed the index.php) is not shown (just a blank white page). When the $config['enable_query_strings'] is set 'False', then the https://example.com/file returns 404, but the string url is shown correctly!


RE: Removing .php extension gives 404 - sj2022 - 01-10-2022

After spending several hours, going through the entire CodeIgniter scripts, I found a hack. Not ideal, but works fine for me.

Under system/URI.php, within the public function __construct(), based on current full URL, I switch between $protocol = 'REQUEST_URI' and $protocol = 'QUERY_STRING', when the URL includes and does not include the name of the application's folder, respectively.