I know this has been covered before but I cannot find an answer to this, I have always used this;
This has always worked in my current project and all of a sudden it is not working in any of my browsers I would like to figure out the problem and fix it instead of using
I also have error reporting enabled and it shows no errors
Any ideas why it will not work? asked Aug 6, 2009 at 23:18
JasonDavisJasonDavis 47.2k97 gold badges306 silver badges527 bronze badges 2 Try:
See what you get. You shouldn't use ^ (xor) in your error_reporting() call because you're unintentionally asking for all errors EXCEPT notices and warnings.. which is what a 'headers already sent' error is. Edit: Also try putting flush() right above your header() call. answered Aug 6, 2009 at 23:21
4 COMMON PROBLEMS:1) there should not be any output (i.e. 2) there should not be a white-space(or newline) before 3) GOLDER RULE! - the file (and other 4) When redirecting, after 5) Recommended practice - always use 301 or 302 in reference:
6) If none of above helps, use JAVSCRIPT redirection(but it's highly not recommended By Google), but it may be the last chance...:
answered Jun 19, 2015 at 21:20
T.ToduaT.Todua 50.1k19 gold badges217 silver badges213 bronze badges 1 Try removing the Space Between location and the first h in http.
turns into
I had this problem on my WAMP Server. Although it shouldn't be the problem, considering that is how it is documented in the PHP documentation. But you should probably try it anyway. I know it has worked for me in a number of cases. answered Aug 6, 2009 at 23:19
Tyler CarterTyler Carter 59.7k20 gold badges126 silver badges148 bronze badges 2 try this. worked for me.
answered Apr 23, 2012 at 7:25
kartokarto 3,3688 gold badges41 silver badges66 bronze badges Also when you are using the header function it has to be the first thing called before any text (even a space) is written to the client, so check again that there is no spaces being output prior to your call even before th
answered Aug 6, 2009 at 23:22
Toby AllenToby Allen 10.8k11 gold badges73 silver badges124 bronze badges 1
It may be strange solution but try this, change the page encoding from utf8 to ANSI and it will work. use any text editor and save the page as ANSI encoding and upload it to your online server. answered Jun 11, 2012 at 9:50
1 Adding ob_start() solved this issue. answered Apr 27, 2016 at 10:17
Try this (working for me):
Instead of
Bhargav Rao 47.3k27 gold badges121 silver badges137 bronze badges answered Apr 1, 2017 at 19:39
What exactly happens when you visit the page? You can try Firebug or any other tool that allows you to analyze HTTP headers and check if the redirect really happens and whether the answered Aug 6, 2009 at 23:22
Adam ByrtekAdam Byrtek 11.7k2 gold badges31 silver badges30 bronze badges You should also verify that you are redirecting to a valid location, and that the location has proper 404 and 500 error messages/pages setup. It could be that you are simply redirecting a bad place. answered Aug 6, 2009 at 23:24
arbalesarbales 5,2834 gold badges32 silver badges40 bronze badges Weird, but removing blank lines in php worked for me :-\ code before:
code that worked:
rlemon 17.2k14 gold badges91 silver badges123 bronze badges answered May 20, 2013 at 9:11
If your index page is a html file, it may not work. Change it to index.php and use this code:
answered Apr 19, 2017 at 2:11
Emre AYDINEmre AYDIN 6748 silver badges10 bronze badges I actually had a case similar to this where I had an admin page that was included at the top of all my other pages. At the top of each page below the line:
I would have the php logic:
The problem with this was that somewhere else I was also calling/manipulating the What happened was that before it even got to any of the php/html in my views it evaluated whether or not someone was logged in ( Rather than putting the logic in every view file, put it in your controller once, before your switch. Works like a charm! This is useful if you don't want anyone to access any of the sensitive views unless they log in. In my case this was important for my CMS. However, if there are some files that you want to be viewable without logging in then I think the original logic would be sufficient. It seems like you already found a solution but hopefully this can be helpful if you run into this error again. :) answered Mar 20, 2018 at 20:10
Matt CroakMatt Croak 2,6802 gold badges15 silver badges30 bronze badges |