Here is my Php script redirect into admin page ...this code working fine in localhost but i will go the server is not redirected
i dont know ehy its happening right now ... any help guys...

if ($this->session->userdata('admin_login') == 1)
redirect(base_url() . 'index.php?admin/dashboard', 'refresh');

Hi, there are two possible reasons:

  1. the url helper is not loaded
  2. missing trailing slash in application/config/config.php $config['base_url']:

    $config['base_url'] = 'http://domain.tld'; # <- missing final /

i can check my url its correct ...but my page cannot be redirected in admin dashboard ...but localhost it should be working fine ...

Ok then what happens to the page? Is it blank? Try to change the ENVIRONMENT to development that should show the errors, this can be set in the index.php page, otherwise check CI error log.

@cereal If you means change and replace ENVIRONMENT to DEVELOPMENT

No, open the main index.php file, in the first lines, depending on the CodeIgniter version in use, you should see (for version 2.*):

define('ENVIRONMENT', 'development');

while, for version 3.*:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

Be sure the value is development.


With version 3.* it's possible to push a server environment variable to define the environment through the .htaccess file. For example:

SetEnvIf Host www.domain.tld$ CI_ENV=production

The same can be applied at server config, so if you're using CI 3.* be sure your hosting is not setting this by default. It can be overridden by replacing the define() with the CI 2.* version code string.

@cereal ok i will do it