Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

PHP header not redirecting- How we fix it?

by | Feb 9, 2021

Wondering how to fix PHP header not redirecting issue? We can help you.

This redirection error occurs due to some incorrect output buffering settings and wrong header formats.

At Bobcares, we often receive requests to fix redirection errors in PHP as part of our Server Management Services.

Today, let’s discuss this error in detail and see how our s Support Engineers fix it effectively.

Steps to fix PHP header not redirecting

Before going into the steps for fiing this issue let’s see some uses of PHP header?

The header() function in PHP sends a raw HTTP header. This raw data contains the request made by the server as information.

And, we call header() before any actual output is sent. It gives a clear idea about the object sent in the message body.

Also, the Location: parameter of the header returns a redirect status code to the browser.

Usually, we can redirect it either to a URL or some file.

In PHP, redirection to a URL will be of the following format:

< ?php header("Location:"); ?>

Similarly, to redirect to a file, we use the following command:

<?php header("Location: anotherDirectory/anotherFile.php"); ?>

Often this redirection results in some tricky errors, we will see how our Support Engineers fix them.

Fixing PHP header not redirecting

PHP redirections are usually set when we get failed sessions. We can check this with the code given below:

|| (trim($_SESSION['SESS_MEMBER_ID']) == '')
AND !isset($fb_login)
) {

For failed session logins, we will try redirection to another page and this is when we notice that redirection has failed and a black page showed up.

This generally happens due to an error with output buffering.

If we use header(“Location: “);, then it is necessary to use ob_start(); earlier in the script.

ob_start() function will turn the output buffering ON. While output buffering is active no output is sent from the script other than headers until we call ob_end();

Calling header(“Location: “); after content has already been output to the browser can cause problems.

So, we ensure that no output is sent before calling the header.

Setting ob_start() at the beginning of the PHP file heps to resolve the error.

Similarly, errors in the header format can also cause redirection failures.

It is important to make the “Location” start with uppercase. Also, the header contents must be inside double-quotes.

[Still facing PHP redirection errors?- We’ll help you.]


In short, the PHP header not redirecting error occurs mainly due to the absence of ob_start() function, incorrect header formats, and so on. Today we discussed this error in detail and saw how our Support Engineers fix this for our customers.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.