I'm having some issues with CodeIgniter redirects on Heroku. Here is the URL:

http://sergei-game.herokuapp.com/

In particular, what is happening is that the redirects (/controller/function) are being appended to the URL rather than replacing /controller/function in the URL.

I do not have these issues when I navigate to the same URL on localhost.

Here is the relevant code in the main controller:

public function index() {
    redirect('gameplayer/login', 'refresh');
}

public function login() {
    if (isset($_SESSION['email'])) {
        // if logged in, go to character selection page
        redirect('gameplayer/viewAccount');
    } else {
        $this->load->view('auth/login');
    }
}

Here is my .htaccess file

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

I took a look at the Heroku logs, but they don't make very much sense to me.

有帮助吗?

解决方案

You don't have the correct base URL configured in CodeIgniter. In the configuration file located at application/config/config.php find the line $config['base_url'] and set it to your URL. In your case it should be $config['base_url'] = 'http://sergei-game.herokuapp.com/';

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top