• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
controller redirect to method fails

Following up: Full code examples below of what worked and didn't...

Thanks for all the suggestions.  Most failures end with a CI4 code exception: SYSTEMPATH/HTTP\Exceptions\HTTPException.php at line 106

The root problem for me is simply vague documentation about reverse routing.  I've just no desire to poor through the CI4 system code.
I should mention I'm writing modules in different directories and namespaces with a "global" config, so I needed a general solution to redirect routing, etc...

PHP Code:
<?php namespace App\Controllers;
Home extends Controller
    // Just jump to a different controller...  
        // Remember to add the route: $routes->get('/(:any)', 'Home::$1');
public function index()
// in CI3:  redirect('dummy');  // traditional.

               // in CI4:
return redirect()->tobase_url('dummy') ); // this works (preferred solution I think)

        //return redirect()->to('ci4/dummy'));         // this works (/ci4 is my new "public" dir)
        //$this->response->redirect('dummy');       // this also works
                //$this->response->redirect(base_url('dummy')); // this version also works

        // return redirect("dummy");              // fails with CI code exception
        // return redirect(base_url('dummy'));    // fails with CI code exception
        // return redirect('App/Controller/Home::dummy');    // fails with CI code exception

public function dummy()
"Dummy route.";


Messages In This Thread
controller redirect to method fails - by devops - 03-12-2019, 08:25 AM
RE: controller redirect to method fails - by devops - 03-13-2019, 01:00 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.