简体   繁体   中英

Getting 503 Service Unavailable on Codeigniter in Apache Server

I am working with Codeigniter 3 on an Apache server (XAMPP) and I have a problem on my live server (CentOS). When I try to load a new view, no problem occurs. But when I try to load a new view multiple times (like 5 times) before the old view finishes loading, the server crashes and gives me a 503 error.

We discovered this error when a user tried to use the navigation menu and seeing that the page was slow to load, because the database is slow, he quickly tried to load a new page.

This error occurs in all views, no matter how simple or complex they are.

Here is an example of a view that generate the error.

<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Example_controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('example_model');
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->library('session');
        $this->load->helper('url');
    }

    public function index()
    {
        $data['information'] = $this->example_model->get_data();

        $this->load->view('header');
        $this->load->view('body', $data);
        $this->load->view('footer');
    }
}

In this example, the database function is a very simple Select query. I'm using Oracle SQL database.

I also tried to change the .htaccess file to allow more time to timeout server but that didn't work.

This is my current .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

I have been looking for an answer for a long time, I will be very grateful for any help you can give me. Thanks in advance.

I think you can't set the 503 HTTP Status using the redirect() function that CI provides. But you can set the 301 code (temporal redirection), which means that the search engine will know that your page is temporally redirected and it will not index the maintenance page.

More info here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM