Welcome Guest, Not a member yet? Register   Sign In
[RESOLVED][Apache/PHP5] Accessing controllers throws an 404 error
#1
Question 
(This post was last modified: 01-24-2018, 06:46 AM by dfun.)

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!
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 01-24-2018, 06:46 AM by dfun. Edit Reason: Fixed! )

(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!
Reply
#4

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...
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB