Codeigniter echoing [::1] instead of localhost Codeigniter echoing [::1] instead of localhost codeigniter codeigniter

Codeigniter echoing [::1] instead of localhost


It's because of your base_url is empty.

In config/config.php

$config['base_url'] = 'http://localhost/project_name';

Something more interesting about http://\[::1\]/


You need to edit your $config['base_url'] as follows,

$config['base_url'] = '';$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");$config['base_url'] .= "://" . $_SERVER['HTTP_HOST'];$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);

File location: codeigniter/application/config/config.php
Use above code to get dynamic url.


More accurate and dynamic way

$root = "http://".$_SERVER['HTTP_HOST'];$root .= dirname($_SERVER['SCRIPT_NAME']);$config['base_url'] = $root;

Though you can still use port.