D
D
Dmitry2015-10-30 11:55:51
PHP
Dmitry, 2015-10-30 11:55:51

How to setup redirect after 403 Forbidden header in php?

Hello. I wanted to do this: when trying to request a specific page, check if the user is not authorized - send a 403 code and redirect, for example, to the main one.
What do I do:

header("HTTP/1.1 403 Forbidden");
header("Location: http://" . $_SERVER['HTTP_HOST']);
exit();

But when viewed in a browser, I see the following answer:
Status Code:302 Found
It turns out that 403 does not shine anywhere .. The question is why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton B, 2015-10-30
@bigton

What if you try it?

header("HTTP/1.1 403 Forbidden");
header("Location: http://" . $_SERVER['HTTP_HOST'], TRUE, 403);
exit();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question