Welcome Guest, Not a member yet? Register   Sign In
spontaneous 404 error
#1

[eluser]diego.greyrobot[/eluser]
Hi all, I'm completely perplexed by this problem i ran into all of the sudden last night. I was adding some code in one of my controllers, when the entire website decides to break. Now, no matter what page i try to visit i get an error 404 page not found, even on the home page.

So I tried to chase the error by inserting exit statements in the code and I traced back the problem to the Router.php file in the libraries folder of the codeigniter system folder. In that file theres a private class method _validate_request() which gets passed a param called $segments, this param is somehow null or corrupt because it causes the function to skip over all the if statements and go right to the show_404() function at the bottom of the method declaration.

I have no idea why this happen, it seemed very spontaneous to me since i was only adding code to a controller when this happened.

I've since reuploaded my codeigniter system folder with no results. What else could be break the Router?
#2

[eluser]TheFuzzy0ne[/eluser]
The only things that come to mind for me are htaccess file, routes.php, and file name case (must be all lower). I reckon that the problem lies in one of those.
#3

[eluser]diego.greyrobot[/eluser]
Hey thanx for replying FuzzyOne!

I checked all those things and finally what solved it was backing up all the files to my pc, deleting them from the server and reuploading them. This seems stupid, I know. I don't know why, but it fixed it and my site comes up just like it's supposed to.
#4

[eluser]diego.greyrobot[/eluser]
It's so strange after my last post, i tried opening the site in FF3 and it still said 404 page not found. So i went back and deleted all the files form the server and uploaded the previously backed up files, and it worked perfectly. Now, again, it works in all browsers. What could that be?
#5

[eluser]TheFuzzy0ne[/eluser]
Have you tried clearing your browser cache?

Which 404 are you seeing? Is it the CodeIgniter one, or the Apache one?
#6

[eluser]diego.greyrobot[/eluser]
Yeah, tried all that. it's the CI error.
#7

[eluser]TheFuzzy0ne[/eluser]
Which 404 are you seeing? Is it the CodeIgniter one, or the Apache one?

EDIT: Scrap that - silly question... It's the CI error you're seeing.

If you want to post your controller/application, I'll gladly take a look at it for you, and see if I can replicate the problem.
#8

[eluser]diego.greyrobot[/eluser]
Cool, yea maybe there's something you can find that I missed. Thanks.

Here's the home controller
Code:
<?php
class Home extends Controller {

    function Home() {
        parent::Controller();
    }
    
    function index() {
        $data['view_data']['top_white_box'] = $this->content_model->get_content('home_page', 'top_white_box');
        $data['view_data']['middle_white_box'] = $this->content_model->get_content('home_page', 'middle_white_box');
        $data['view_data']['top_black_box'] = $this->content_model->get_content('home_page', 'top_black_box');
        $this->load_view('home_view', $data);
    }
    
    function about() {
        $data['view_data']['about'] = $this->content_model->get_content('about_page', 'top_white_box');
        $data['view_data']['site_links_data']['links'] = $this->admin_model->get_banners(true, true);
        $this->load_view('about_view', $data);
    }
    
    function contact() {
        $data['view_data']['contact'] = $this->content_model->get_content('contact_page', 'top_white_box');
        $this->load_view('contact_view', $data);
    }
    
    private function load_view($page, $vdata) {
        $title = str_replace('_view', '', $page);
        $data['head_data']['keywords'] = $this->products_model->get_keywords();
        $data['head_data']['description'] = "Buy Corals at Donavon's Reef";
        $data['head_data']['title'] = ucfirst($title)." Donavon's Reef";
        $data['head_data']['head_items'] = array("[removed]
            Settings.page = '" . $title . "_page';    
        [removed]");
        $data['view'] = $page;
        
        //append view data to data
        if($vdata) $data += $vdata;
        
        //echo "<pre>"; print_r($data); die();
        $this->load->view('main_view', $data);
    }
    
}

/* End of file home.php */
/* Location: ./controllers/home.php */

Currently, the above code is operational. Let me know if theres anything else i should post.
#9

[eluser]TheFuzzy0ne[/eluser]
It works great for me (aside from the expected errors).

Please post your .htaccess file, and the request URI part of the URL (e.g. /about or /home/about etc...).
#10

[eluser]diego.greyrobot[/eluser]
.htaccess
Code:
DirectoryIndex index.php

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond $1 !^(index\.php|images|css|js|swf|xml|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

I'm not folowing u on the request uri thing. to view the home page or the about page the url would be www.donavonsreef.com/home or /home/about

hope that answers it.
thanks so far for your help.




Theme © iAndrew 2016 - Forum software by © MyBB