Welcome Guest, Not a member yet? Register   Sign In
When does CodeIgniter return 404 headers, exactly?
#1

[eluser]besson3c[/eluser]
For some reason, the URLs associated with my CodeIgniter app are returning 404 errors according to my browser's logs. The content associated with these pages returns fine, there is no noticeable problem that can be seen through the browser with one exception...

The exception is with Prototype apps that utilize the "onSuccess" callback. Because these URLs are all generating 404 headers, this callback is not triggered - I have to use the onComplete callback instead.

Again, to re-emphasize, I'm not getting the 404 error message page, my pages are rendering their correct content as expected. There is clearly something related to the way my content is served by the server that is triggering these headers, and I'm trying to trace down what the cause might be?

My .htaccess file is pretty standard:

Quote:RewriteCond $1 !^(index\.php|albumimages|wordpress|styles|js|nm_webkit|robots\.txt)
RewriteRule ^(.*)$ /index.php/main/$1 [L]

I still get 404 errors appearing in my log files when I access my controller's functions via:

http://mydomain/index.php/mycontroller/myfunction

So, I'm not convinced that the problem is with mod_rewrite. I'm not seeing any 404 messages in my CodeIgniter logs, it appears to be happily serving these pages with the final log message "Final output sent to browser" and its total execution time (I'm also getting this output in my browser, like I said).

Any other ideas as to what might be causing these 404 headers being sent?
#2

[eluser]besson3c[/eluser]
Anybody?
#3

[eluser]Colin Williams[/eluser]
Look at your apache error log. It will tell you what is generating the 404. Likely a missing asset (img, js, css, favicon, robots.txt, etc)
#4

[eluser]besson3c[/eluser]
The pages themselves are returning as 404s, for example:

Quote:MyIP - - [08/Nov/2009:11:20:09 -0500] "GET / HTTP/1.1" 404 5453 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"
#5

[eluser]JoostV[/eluser]
Run your pages through firebug. It will tell you exactly what was requested and what was returned; for every page, asset, ajax call, etc.
#6

[eluser]besson3c[/eluser]
I have, I rely heavily on Firebug for everything I do Smile Firebug shows the correct output, there is no visible problem on the site itself - all of my content displays as if each page was being returned with status code 200.

The problems are with the Prototype onSuccess/onComplete callbacks being tripped up by the 404 header, and it also occurred to me that as far as log analysis goes packages like AWStats would probably be considering these pages 404s because of this header, which is not desirable.

Does this make sense?
#7

[eluser]JoostV[/eluser]
A nicely rendered page does not always mean the status is 200, of course.

According to the usage log exerpt you posted the 404 is returned on URL '/', so the webroot for the domain for this log.

That means the status code for webroot '/' for that domain in your Firebug in the Net panel should also say 404. Your ajax calls also show up in Firebug, so if any of them returned 404 you should see that in your Net panel as well.

Are you sure you are looking at the right Apache user log Smile I have never encountered a situation where the Apache tells me 404 and Firebug tells me 200.
#8

[eluser]besson3c[/eluser]
[quote author="JoostV" date="1257775922"]A nicely rendered page does not always mean the status is 200, of course.[/quote]

Good point!

Quote:According to the usage log exerpt you posted the 404 is returned on URL '/', so the webroot for the domain for this log.

That means the status code for webroot '/' for that domain in your Firebug in the Net panel should also say 404. Your ajax calls also show up in Firebug, so if any of them returned 404 you should see that in your Net panel as well.

Are you sure you are looking at the right Apache user log Smile I have never encountered a situation where the Apache tells me 404 and Firebug tells me 200.

I'm seeing the 404s in both Firebug and my Apache logs, yet the content renders fine as long as I use Prototype's onComplete callback (and I see the correct content within Firebug).

Is there *anything* in CodeIgniter that could generate a false 404 header?
#9

[eluser]JoostV[/eluser]
Not that I know of, but maybe someone else can shed some light here.




Theme © iAndrew 2016 - Forum software by © MyBB