CodeIgniter Forums

Full Version: [RESOLVED][Apache/PHP5] Accessing controllers throws an 404 error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey!

I'm rather new to CodeIgniter, but I want to use it to implement a RESTful API server for a project at work.
I downloaded a fresh copy of version 3.1.7, unpacked it, installed the dependencies via composer and put it on our local development server.
At first glance it worked as intended, it showed the Welcome controller without any troubles.

I then created my own controller with the documentation as a guideline. After then trying to access it like described in the docs all it gave me was an 404 Not Found error from the Apache Server.
(tried: http://server.local/ciproject/index.php/orders/ and http://server.local/ciproject/orders/)


After trying several things with the config.php and their options, modifying the .htaccess, even changing the main index.php paths to be absolute paths to my project.... still no luck. The CI logger option didn't even seem to note anything when I tried calling the controller, so to me it looks like as if the Apache/PHP just ignores something and tries to find a directory called like the controller, but obviously can't.
(For reference: I can access the controller via the http://server.local/ciproject/index.php?c=orders option when I activate it in the config.php)

On my local machine with a standard XAMPP (PHP5) installation CodeIgniter controller handling works like intended without any troubles. (So I doubt that the Controller has any issues whatsoever.)

My colleague who maintains our servers has no idea what the issue might be, same with me. I do either suspect the Apache2 server itself or maybe something with the PHP configuration. But what would cause said issues?

I'd really appreciate if anyone here can help me out or maybe even had the same problem. For now I'm kinda forced to start developing on my local machine, until the issues on the development server are fixed.

Thank you!
First off I would check the php version running on the server.

Check the php installation and that all the right modules are compiled into it.

Check the Apache installation also.
(01-24-2018, 04:22 AM)InsiteFX Wrote: [ -> ]First off I would check the php version running on the server.

Check the php installation and that all the right modules are compiled into it.

Check the Apache installation also.

Hey.

The php version running is 5.4.45. (Yes, I know, rather ancient, but I already tell everyone that we should prioritize migrating to PHP 7 ASAP.)

As for the modules, I can't really say which are included vanilla and which would be known to cause the issue.

I've tried using PHP 5.4.45 on my local machine just now and CodeIgniter worked as intended with it.

If you can hint me to where to look for the information needed to figure out the issue, I'll gladly post those. Or maybe you might have an idea which module or config property could be the perpetrator?

Edit: I found the problem! I actually found a different .htaccess snippet from InsiteFX here on the forums and that did the trick. I think it had to do with how Apache integrates PHP. Thanks though!
You can view the server error logs for information.

Also you can run CodeIgniter's Profiler to see what it says.

If this is a live server do not leave this on it but you

Create a script to show you the php info see phpinfo below

DO NOT LEAVE THIS ON A LIVE SERVER!!!

PHP Code:
<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

Hope this helps...