PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 12, 2022

[FIXED] redirectint to localhost:8080 on codeigniter 4

 February 12, 2022     codeigniter, codeigniter-4, php     No comments   

Issue

I'm trying to make a logout function on codeigniter 4, and I'm realizing there is different things from v3

public function logout(){
        session_start();
        session_destroy();
        
        return redirect()->to("/");
    }

this is not redirecting me to my virtualhost / route its redirecting to localhost:8080/


Solution

That's because you need to set your base url in /Config/App.php

/* public $baseURL = 'http://localhost:8080/'; // <-- what is there now */
public $baseURL = 'https://www.mywebsite.com/'; // <-- change to your url

Then you can reference it

return redirect()->to(site_url()); // or
return redirect()->to("/");


Answered By - Kinglish
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing