CodeIgniter Forums
Why am I encountering 404 errors with CodeIgniter controllers on a new server? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Why am I encountering 404 errors with CodeIgniter controllers on a new server? (/showthread.php?tid=88088)



Why am I encountering 404 errors with CodeIgniter controllers on a new server? - TatwanFilemdar - 07-18-2023

I encountered an interesting issue while transferring a fully functional CodeIgniter app to a new server. After updating the base URL in the config.php file and configuring the database parameters accordingly, I'm facing a problem where all controllers I attempt to access on the new server result in a 404 error. However, when I navigate to the base URL, the default controller (welcome.php) defined in routes.php renders correctly in the browser.

Based on this observation, it appears that CodeIgniter is running properly on the new server, but there may be an underlying routing issue that I haven't been able to identify.

My current .htaccess file contains the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
This .htaccess configuration worked fine on the previous server. However, I'm uncertain about what might be causing the problem on the new server.

I would greatly appreciate any insights or suggestions regarding what I might be doing wrong in this situation.


RE: Why am I encountering 404 errors with CodeIgniter controllers on a new server? - InsiteFX - 07-18-2023

PHP Code:
RewriteRule ^(.*)$ /index.php?/$[L]

// try changing to this one.
RewriteRule ^(.*)$ /index.php/$[L