Welcome Guest, Not a member yet? Register   Sign In
redirect url helper redirect to localhost

(05-13-2015, 07:19 PM)Edwin Wrote:
(05-08-2015, 01:53 AM)rtorralba Wrote: Hi,

When a call a redirect url helper function this function as following:


redirect to http://localhost/index.php/controller/method

If I set base_url variable on config file works correctly and redirect to http://myvirtualhost.com/index.php/controller/method but this not was necessary on codeigniter 2 and can be a problem because we must to define a base_url per environment.


Hi rtorralba,

if i not get you wrong, what you mean is without define base_url is only working for CI 2 but not for CI 3. So i guess what you want is a dynamic base_url. 

What you can do is.. 

PHP Code:
$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']); 

update this base_url, this script will auto help you defined base_url and even work in localhost.

This is worse than leaving it blank ... it ignores security checks.

Messages In This Thread
RE: redirect url helper redirect to localhost - by Narf - 05-14-2015, 12:37 AM

Theme © iAndrew 2016 - Forum software by © MyBB