Part of the EllisLab Network
   
 
404 error when not using a controller
Posted: 18 October 2006 09:17 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  10-09-2006

This post: http://codeigniter.com/forums/viewthread/46397/

Probably belongs here…

 Signature 

http://www.totali.co.nz - Real IT
http://www.oscar.school.nz - Internet Filtering

Profile
 
 
Posted: 18 October 2006 09:20 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2541
Joined  12-21-2001

If the error happens only when using mod_rewrite then it’s not likely to be a CI issue.

 Signature 
Profile
MSG
 
 
Posted: 18 October 2006 09:32 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  10-09-2006

Hi Rick,

I shall try it without mod_rewrite

I’ve never used mod_rewrite, so first time user of that while learning CI (which I think is awesome BTW).

Any ideas?

My mod_rewrite would be putting the index.php/ part in there, so I can’t quite work out what else it could be.

 Signature 

http://www.totali.co.nz - Real IT
http://www.oscar.school.nz - Internet Filtering

Profile
 
 
Posted: 19 October 2006 12:21 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  10-09-2006

Ok here is what I think happens.

It’s not related to mod_rewrite.

If there is no controller specified, CI give you a 404.

But… That 404 page doesn’t allow you to use any of the nice stuff CI does, like the URL helper.  So all my anchor and base_url commands don’t work.

That either limits me to a hard coded URL, or a nasty 404.

 Signature 

http://www.totali.co.nz - Real IT
http://www.oscar.school.nz - Internet Filtering

Profile
 
 
Posted: 19 October 2006 11:47 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2541
Joined  12-21-2001
HushPe - 19 October 2006 12:21 AM

But… That 404 page doesn’t allow you to use any of the nice stuff CI does, like the URL helper.  So all my anchor and base_url commands don’t work.

Right, that’s because the CI object doesn’t exist until a valid controller is found.  If there is no controller, CI won’t ever be fully instantiated (remember that controllers extend the main CI controller, which allow everything to work as it does), so helpers and such won’t be available.

There’s another reason that I chose to keep 404 pages lean and simple:  Performance.  If you’ve ever examined the server logs on a busy site you’ll see that crawlers like Google can hammer a site with invalid requests.  I’ve seen search engines produce literally thousands of hits to nonexistent pages.  Do you really want your 404s to use all the resources of your application, just like you would with valid pages?  I sure don’t.  IMO 404s should be as lightweight as possible since their only purpose is to send a 404 header and a bit of info.

 Signature 
Profile
MSG
 
 
Posted: 20 October 2006 12:06 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  10-09-2006

Hi Rick,

Thanks for that.  I was after a confirmation of how it worked.  And was considering tone-ing it down a bit.  I haven’t had many probs with the Google bot, but I could see the potential for problems with massive dynamic sites.

Thanks again.

 Signature 

http://www.totali.co.nz - Real IT
http://www.oscar.school.nz - Internet Filtering

Profile
 
 
Posted: 09 November 2006 02:28 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  12
Joined  09-18-2006

hi,
is it possible to echo the “not existing filename” it is trying to load, just just the plain 404 error and leave u guessing.

Rick Ellis - 19 October 2006 11:47 PM
HushPe - 19 October 2006 12:21 AM

But… That 404 page doesn’t allow you to use any of the nice stuff CI does, like the URL helper.  So all my anchor and base_url commands don’t work.

Right, that’s because the CI object doesn’t exist until a valid controller is found.  If there is no controller, CI won’t ever be fully instantiated (remember that controllers extend the main CI controller, which allow everything to work as it does), so helpers and such won’t be available.

There’s another reason that I chose to keep 404 pages lean and simple:  Performance.  If you’ve ever examined the server logs on a busy site you’ll see that crawlers like Google can hammer a site with invalid requests.  I’ve seen search engines produce literally thousands of hits to nonexistent pages.  Do you really want your 404s to use all the resources of your application, just like you would with valid pages?  I sure don’t.  IMO 404s should be as lightweight as possible since their only purpose is to send a 404 header and a bit of info.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64453 Total Logged-in Users: 19
Total Topics: 80961 Total Anonymous Users: 0
Total Replies: 435695 Total Guests: 192
Total Posts: 516656    
Members ( View Memberlist )