Welcome Guest, Not a member yet? Register   Sign In
Redirect Not Working CI4
#6

(This post was last modified: 11-12-2019, 02:51 AM by Chivinsdev.)

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
Reply


Messages In This Thread
Redirect Not Working CI4 - by Programaciones Web - 11-07-2019, 07:57 AM
RE: Redirect Not Working CI4 - by adelbak - 11-07-2019, 11:52 AM
RE: Redirect Not Working CI4 - by dave friend - 11-08-2019, 06:22 AM
RE: Redirect Not Working CI4 - by Chivinsdev - 11-11-2019, 09:21 AM
RE: Redirect Not Working CI4 - by Juan Fajardo - 06-02-2020, 10:49 AM
RE: Redirect Not Working CI4 - by kilishan - 11-11-2019, 09:58 AM
RE: Redirect Not Working CI4 - by InsiteFX - 11-12-2019, 04:07 AM
RE: Redirect Not Working CI4 - by Gary - 04-18-2020, 03:22 PM
RE: Redirect Not Working CI4 - by Gary - 04-18-2020, 07:16 PM
RE: Redirect Not Working CI4 - by Leo - 04-20-2020, 02:42 AM
RE: Redirect Not Working CI4 - by jim1001 - 05-21-2020, 04:26 AM
RE: Redirect Not Working CI4 - by dave friend - 05-21-2020, 01:02 PM
RE: Redirect Not Working CI4 - by Leo - 05-22-2020, 09:46 AM
RE: Redirect Not Working CI4 - by ivanfdr - 04-22-2020, 09:16 PM
RE: Redirect Not Working CI4 - by abeni_ab - 07-22-2020, 09:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB