Welcome Guest, Not a member yet? Register   Sign In
404 Error Pages Don't Work for Me
#1

[eluser]Burak Erdem[/eluser]
Hi,

I was working with ZendFramework before and decided to use CodeIgniter for my new project. I just started to develop a new application with CI. Everything is working great except those 404 error pages.

When I try to load a page that doesn't exist (like http://localhost/user/abcd which "abcd" doesn't exist), Google Chrome endlessly tries to load that page, and Firefox tells me that this page doesn't exists. But no sign of CI's own 404 error page. I have the controller but not the correct action in it, so I expect to see an error page.

I also tested this with a brand new CI installation.

I'm on a Windows Vista machine, on my localhost and using Zend Server CE with Apache 2.2, MySQL 5.0 and PHP 5.2.9 installed.

My .htaccess file is like below;
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#2

[eluser]Cro_Crx[/eluser]
Just out of interest if you browse to http://localhost/user/index.php/abcd "in which abcd doesn't exist". Do you get an error message then?
#3

[eluser]Burak Erdem[/eluser]
@Cro_Crx It doesn't show any error page in Google Chrome because Chrome never stops loading the page. Firefox gives the standard "File Not Found" error. Let me explain this a bit more.

I have a controller named "user" and a "details" function in this controller. When I browse to http://localhost/public/user/details my browser successfully displays the page. But when I try to browse like http://localhost/public/user/login (which "login" function doesn't exist) Google Chrome never stops loading, and Firefox gives the above error.

Btw I've changed the directory structure a little bit. But I think directory structure has no effect on this because when I try this with the standard CI installation, this situation doesn't change.

This is what my directory structure looks like.

[Image: http://img18.imageshack.us/img18/1487/74675804.th.png]

Here is my /public/.htaccess file
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

And my /public/index.php file (removed comments, edited $system_folder and $application_folder)
Code:
&lt;?php
error_reporting(E_ALL);
$system_folder = "../codeigniter";
$application_folder = "../application";

if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    $system_folder = str_replace("\\", "/", $system_folder);
}

define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
#4

[eluser]Burak Erdem[/eluser]
I'm still having this 404 issue. But I just realized that show_404() is also not working for me. Google Chrome still endlessly loops and Firefox shows default error page.

Please tell me something to solve this 404 issue. Thanks..
#5

[eluser]devbro[/eluser]
[quote author="demods" date="1249872067"]I'm still having this 404 issue. But I just realized that show_404() is also not working for me. Google Chrome still endlessly loops and Firefox shows default error page.

Please tell me something to solve this 404 issue. Thanks..[/quote]

Just for testing. create a simple page that return 404 using simple php (no CI) and see what happens. There is a chance that what you are describing is something built into the ff and chrome.

browsers may act differently under diff conditions. for example I wanted to view an rss-xml but no matter what you do ff won't let you do it easily.
#6

[eluser]Burak Erdem[/eluser]
OK, now I see there is a problem. I just did what you said, devbro. I used the following code to generate a native PHP error;

Code:
&lt;?php
header("HTTP/1.0 404 Not Found");
exit;
?&gt;

It's still the same. Endless loop in Google Chrome and default error page in Firefox. Well, I don't understand what the problem is and I don't know what to do now Smile

I'm on a Windows Vista machine and I use Zend Server CE to develop my application. Is there an option in php.ini or httpd.conf that prevent to produce errors?
#7

[eluser]devbro[/eluser]
[quote author="demods" date="1249873078"]OK, now I see there is a problem. I just did what you said, devbro. I used the following code to generate a native PHP error;

Code:
&lt;?php
header("HTTP/1.0 404 Not Found");
exit;
?&gt;

It's still the same. Endless loop in Google Chrome and default error page in Firefox. Well, I don't understand what the problem is and I don't know what to do now Smile

I'm on a Windows Vista machine and I use Zend Server CE to develop my application. Is there an option in php.ini or httpd.conf that prevent to produce errors?[/quote]

oki then here is the dirty quick, work around for you:
remove the first line from system/application/errors/error_404.php

that should aleast show the error page for now.
#8

[eluser]Burak Erdem[/eluser]
devbro you're the man Smile That really solved the problem, thank you so much.

Now it's time solve the real problem. I know that's not related with CI anymore, but how could this be and what do I have to do to solve my PHP error issue?
#9

[eluser]devbro[/eluser]
[quote author="demods" date="1249873748"]devbro you're the man Smile That really solved the problem, thank you so much.

Now it's time solve the real problem. I know that's not related with CI anymore, but how could this be and what do I have to do to solve my PHP error issue?[/quote]

I don't think it is a php problem. i would further try to create 404 by other means such as .htaccess . if the problem persist then I suggest to submit a ticket to both ff and chrome developement teams.


If i am wrong and it is indeed a php problem then taking a look at the actual response from the server should give some light to what is happening. maybe telneting to the server on port 80 and typing :
GET http://www.devbro.com/asdasdasdas
#10

[eluser]Unknown[/eluser]
Hello,
I had same problem and I found solution for this. Tongue
Problem is with PHP loader.
php-cgi - not working correctly for me (I had Zend Server CE)
php5apache2_2.dll - ALL working fine.

LiborM




Theme © iAndrew 2016 - Forum software by © MyBB