Welcome Guest, Not a member yet? Register   Sign In
"Page not found" after uploading the site to production server
#1

[eluser]jstuardo[/eluser]
Hello...

I have this problem, now when uploading the developed site to production.

My development server has IIS 6.0 and CodeIgniter works correctly there.

I developed a site whose default controller is "frontend/evento". That way, I can access it using either:

http://corridacoanil/index.php/frontend/evento
or
http://corridacoanil/

The problem I have now is when I uploaded the site to the production server, which has Apache Web Server under Linux O.S., the site doesn't work (it shows a Page not Found error)

If I use:
http://desacoanil.hosting.cl

The home page loads correctly, but when I use
http://desacoanil.hosting.cl/index.php/frontend/evento

it does not.

the routes.php file has $route['default_controller'] = "frontend/evento";

So, why I cannot access the page using the whole URL? The same problem happens with all other controllers.

Not even Welcome page works (http://desacoanil.hosting.cl/index.php/welcome)

The log file shows the following:

Code:
DEBUG - 2009-06-14 18:54:56 --> Config Class Initialized
DEBUG - 2009-06-14 18:54:56 --> Hooks Class Initialized
DEBUG - 2009-06-14 18:54:56 --> URI Class Initialized
ERROR - 2009-06-14 18:54:56 --> 404 Page Not Found --> index.php

of course index.php file is present. If I use http://desacoanil.hosting.cl/index.php the default controller is loaded.

Any help will be greatly appreciated
Thanks

Jaime
#2

[eluser]gtech[/eluser]
Hi Jaime,

have you tried the steps in the [url="http://ellislab.com/codeigniter/user-guide/installation/troubleshooting.html"]trouble shooting guide[/url]?

i.e:

step 1)Try alternate URI_PROTOCOL settings in the config
step 2)set $config['index_page'] = "index.php?"

hope this helps.
#3

[eluser]jstuardo[/eluser]
Hello.. the problem is not as easy to resolve.

By following the PHP code I found where the problem is:

index.php file loads CodeIgniter.php file. That file loads some classes. Only ONE of those classes cannot be loaded. It is Router.php.

Digging inside it, I found that the problem is in function _validate_request($segments). This is the whole code of it:

Code:
function _validate_request($segments)
    {
        // Does the requested controller exist in the root folder?
        if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
        {
            return $segments;
        }

echo APPPATH.'controllers/'.$segments[0];
        // Is the controller in a sub-folder?
        if (is_dir(APPPATH.'controllers/'.$segments[0]))
        {        
            // Set the directory and remove it from the segment array
            $this->set_directory($segments[0]);
            $segments = array_slice($segments, 1);
            
            if (count($segments) > 0)
            {
                // Does the requested controller exist in the sub-folder?
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
                {
                    show_404($this->fetch_directory().$segments[0]);
                }
            }
            else
            {
                $this->set_class($this->default_controller);
                $this->set_method('index');
            
                // Does the default controller exist in the sub-folder?
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
                {
                    $this->directory = '';
                    return array();
                }
            
            }

            return $segments;
        }

        // Can't find the requested controller...
        show_404($segments[0]);
    }


$segments parameter is an array of 3 element, whose first element is index.php, so, when
APPPATH.'controllers/'.$segments[0] is used, this is the file that is trying to load:

Code:
system/application/controllers/index.php

Of course, it will be unable to be loaded.

So I have found the problem, but I cannot realize about the solution because I cannot imagine why is happening this. Why $segments contains index.php too? I didn't see where $this->uri->segments was initialized incorrectly. Why does that work in IIS? In IIS, first element of $segments[0] is

Code:
system/application/controllers/backoffice

which is correct.

Any further help will be greatly appreciated.

Thanks
Jaime
#4

[eluser]jstuardo[/eluser]
I have found the origin of the problem:

Somewhere in the code, URI was assigned the value of $_SERVER['PATH_INFO']. In my hosting account the value returned was /index.php/backoffice/evento, but in my IIS server it was: /backoffice/evento.

Why is that? the URL passed to the browser in the hosting account was:
http://desacoanil.hosting.cl/index.php/b...ice/evento

and in my local server was:
http://corridacoanil/index.php/backoffice/evento

I tried with rewrite conditions but with no success.

any help? thanks
Jaime
#5

[eluser]jstuardo[/eluser]
Ufff... that is becoming an unsolved mystery, but finally the solution was to change AUTO uri_protocol to REQUEST_URI in config.php file. In order to change that, I had to find where the problem was so that I don't use blind solutions Smile

Thanks
Jaime
#6

[eluser]Colin Williams[/eluser]
Quote:Hi Jaime,

have you tried the steps in the trouble shooting guide?

step 1)Try alternate URI_PROTOCOL settings in the config

Quote:Hello.. the problem is not as easy to resolve.

Quote:finally the solution was to change AUTO uri_protocol to REQUEST_URI in config.php file



:gulp:
#7

[eluser]Thorpe Obazee[/eluser]
:-)

Maybe gtech is on his ignore list :-P
#8

[eluser]gtech[/eluser]
I would ignore me if I was me Smile




Theme © iAndrew 2016 - Forum software by © MyBB