0

I'm pretty sure this isn't possible and I need to set headers on login.php if $_GET['reason'] isset but can someone clarify that I can't set response code then change location?

header('HTTP/1.1 403 Forbidden');
header("Location: http://domain.com/login.php?reason=ipbanned");

1 Answer 1

1

Right, this is not possible. A "Location" header sets the HTTP response code to 302 Found (or another 3xx redirect code) and you can't send two response codes at a time.

Update:

The correct way to do what you want is to send the forbidden header on the redirected page, i.e. in login.php if $_GET['readon']=='ipbanned', not on the redirecting page.

Sign up to request clarification or add additional context in comments.

3 Comments

If you don't specify a response code, the default is 302. This is overridden if you set one yourself.
So can I set a 403 reponse code and redirect on the same page?
No you can't. You have to do it the other way around (see update)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.