We upgraded our server for a 10 year old website recently and the lowest allowable PHP version the host would install was 7.4. Understandable.
When we moved the old CodeIgniter 2.2.0 site over to the new machine, we were quite surprised with the amount of stuff that was still working. After squashing some environmental and PHP version bugs, we did a QA. Everything is peachy save for the home or "defualt_controller" route stuff.
If I summon any asset or anything routed through https://example.com/***admin/*** by HTTPS, I get 200 with no issues. If I clone static HTML into PHP files and drop them in to directories, they’ll serve securely.
I’ve tooled around with index.php and even core/CodeIgniter.php and the returns to those requests serve 200 OK under HTTPS.
If I request any dynamically generated document on the publicly visible part of the site, it’s constantly HTTPS 302 Found -> HTTP 200 OK
If I do very aggressive .htacccess stuff, the server fights back and the browser goes: "Too many redirects"
Has anyone dealt with this? I am assuming something in the core is silently erroring out?
2
Answers
In this particular case there was a conditional statement in a library that required $_SERVER['HTTPS'] to return TRUE. This server was returning NULL which went to the next condition which summoned force_non_ssl();
Thanks!
From what you have described, it seems like the issue may be related to the settings and configurations of CodeIgniter. CodeIgniter 2.2.0 is quite an old version, and while it is surprising that it works mostly well with PHP 7.4, it can still have compatibility issues.
The behavior you are experiencing is often due to some misconfiguration between the application and the web server. Here are a few steps you can take to help troubleshoot your issue:
In the configuration file of your CodeIgniter application (application/config/config.php), there is a setting for your base URL. Ensure that it is set to use https.
Verify that the .htaccess file is not causing this redirection. Back it up and then try a minimal setup to see if the problem persists.
You mentioned issues with your "default_controller" route, check in your application/config/routes.php to see if there is anything there that could be causing the issue.
If you haven’t done so already, enable error logging in CodeIgniter and check the logs. This might give you a clue about what is going wrong.
Check the server logs, they may provide more detailed information about the error and what’s causing it.
Another possibility is that there are hard-coded HTTP links in your
codebase. If your website code has any hard-coded HTTP links, they
could be causing the redirect from HTTPS to HTTP.
If none of the above suggestions work, it might be worth considering upgrading your CodeIgniter version to a more recent one. This would not only potentially fix your issue but also provide a more secure and updated framework for your application. However, it could also require significant work in updating deprecated function calls and adhering to updated best practices.