Welcome Guest, Not a member yet? Register   Sign In
404 Headers but CI sends correct response
#1

[eluser]Unknown[/eluser]
i'm working on a website at work and recenctly move it via svn to my localserver so i can work from home...

The setup went okay, no majors... but code ignighter sends 404 Not Found on pages along with the correct response...

For example i can load 'localhost/home' and it fires my controller and i get correct view, but CI also send 404 in headers for the page....!! this also happens on my js files...

I can force it to send "200 OK", but doing this on every page seams silly..

Has anyone come accross this problem before...?

I'm using; Code Ignighter: 2.1.0

Apache : 2.0.63

PHP: 5.1.6

this is my .htaccess

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
#2

[eluser]vbsaltydog[/eluser]
http://ellislab.com/forums/viewthread/209718/
#3

[eluser]CroNiX[/eluser]
These lines aren't needed:
Code:
RewriteCond %{REQUEST_URI} ^system.* //(system directory has its own htaccess)
RewriteRule ^(.*)$ /index.php/$1 [L] //(the first one under the system condition)
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js) //(next two lines take care of this)

Look at your server logs. Are you sure you're getting 404s for the actual pages and not missing resources, like favicon.ico, images, or others?
#4

[eluser]vbsaltydog[/eluser]
Enable the logging in CI
Start with a clean CI logfile
Do a single request of a CI page
Examine the CI logfile and see if there was more than one execution of CI

If there was more than one CI execution then look at the page source in the browser for a resource that was loaded by the server and was rewritten to index.php but not found as a controller/method.

Ex.

Your source code includes a call to a js file but it doesn't exist on your server so your htaccess rule sends anything that is not a valid dir/file with the -d -f rules to index.php

index.php sends the js file to CI as a route but there is no such route.

There would be two CI executions, one for the initial URL and one for the js file, the initial call would show the page in the browser but the secondary call for the js file would return the 404 header.

#5

[eluser]Unknown[/eluser]
nice information on 404 Headers

surgical hospital





Theme © iAndrew 2016 - Forum software by © MyBB