Search code examples
php.htaccesscodeigniter-3apache2.2

CodeIgniter 3 on remote server issues


I am trying to setup a production server with a codeIgniter project. All my http request redirects to homepage that login page. I have followed a few instructions from StackOverflow but in vain Following is my config.php settings

$config['base_url'] = 'http://XXXXX.local/';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';

The .htaccess settings

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And my sites-enabled config in apache2 sites-enabled settings

<VirtualHost *:80>
    ServerName    XXXXX.local
    DocumentRoot "/var/www/html/xxx/index.php"
    <directory "/var/www/html/xxx/index.php">
        DirectoryIndex index.php
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </directory>
</VirtualHost>

For e.g. if I open on browser http://XXXXX.local/assets/js/jquery.validate.min.js, it opens homepage

Also my session does not work, it prints empty..I'm setting like $this->session->set_userdata('test','hellow world'); Here's my configuration

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_cookie_name'] = '';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Please help!


Solution

  • The document root in your Apache config needs to be a folder, not a file.

    Change

    DocumentRoot "/var/www/html/xxx/index.php"
    <directory "/var/www/html/xxx/index.php">
    

    to

    DocumentRoot "/var/www/html/xxx"
    <directory "/var/www/html/xxx">
    

    Don't forget to restart Apache after you've updated the config.