The redirect () function does not work for an external URL in CodeIgniter

I want to redirect to www.yahoo.com from my CodeIgniter app. I write the code as follows: redirects ("http://www.yahoo.com");

It works fine on my local computer (Windows vista / WAMP), but when I boot to the linux server it just shows a blank screen and does not redirect.

+4
source share
4 answers

Try using the update method:

redirect('http://www.yahoo.com', 'refresh');

+14
source

you probably want header : header('location: http://www.yahoo.com ');

+1
source

A blank screen usually means a fatal error somewhere. Check out your magazines!

And check your headlines. Wrap it or use an HTTP client to see what is returned.

Debugging helps with these things. We are just random people on the Internet without access to your computer, so without additional information (hell, you did not even indicate which version of CI you are using), we all just guess.

+1
source

Try turning on error_reporting (E_ALL) to see if there are any errors indicating that the output is sent before these headers (indicated in redirect ()).

A common problem I discovered is that download tools (like deploying via FileZilla) sometimes insert lines depending on the transfer mode I assume. I saw the same files that I uploaded via FileZilla at double interval. Most likely you have an empty line at the top of your controller. The best way to find out is to edit this controller on the server (for example, the File Editor or double-check and view it) and see if this is true.

+1
source

All Articles