Quote:I tried everthing with (/), adding to routes of course. With only redirect(); A lot of things... but seems like something changes in CI4 that I dont get it.
SYSTEMPATH/HTTP\Exceptions\HTTPException.php
This worked for me. I created url_helper.php
url_helper.php then insert this code
PHP Code:
<?php
if (! function_exists('current_url'))
{
/**
* Current URL
*
* Returns the full URL (including segments) of the page where this
* function is placed
*
* @param boolean $returnObject True to return an object instead of a strong
*
* @return string|\CodeIgniter\HTTP\URI
*/
function current_url(bool $returnObject = false)
{
$uri = remove_host_http(\CodeIgniter\Config\Services::request()->uri);
$uri = (string) site_url($uri);
$uri = $returnObject ? $uri : remove_host_http($uri);
return $uri;
}
}
//--------------------------------------------------------------------
if (! function_exists('remove_host_http'))
{
function remove_host_http($uri = null)
{
$uri = str_replace('https://'. $_SERVER['HTTP_HOST'].'/', '', $uri);
$uri = str_replace('http://'. $_SERVER['HTTP_HOST'].'/', '', $uri);
return $uri;
}
}
//--------------------------------------------------------------------
And open the codeigniter.php replace storePreviousURL() method at line 978 with the code below
PHP Code:
public function storePreviousURL($uri)
{
// Ignore CLI requests
if (is_cli())
{
return;
}
// Ignore AJAX requests
if (method_exists($this->request, 'isAJAX') && $this->request->isAJAX())
{
return;
}
// This is mainly needed during testing...
if (is_string($uri))
{
$uri = new URI($uri);
}
$uri = str_replace('https://'. $_SERVER['HTTP_HOST'].'/', '', $uri);
$uri = str_replace('http://'. $_SERVER['HTTP_HOST'].'/', '', $uri);
$uri = (string) site_url($uri);
if (isset($_SESSION))
{
$_SESSION['_ci_previous_url'] = (string) $uri;
}
}
I hope this will help you solve your issue