A
A
AJ2012-03-23 13:46:52
Web development
AJ, 2012-03-23 13:46:52

How to fetch URL at 404?

This question arose suddenly ... But how to get the entire URL with a 404 redirect? Those. get the URL from which 404 was rejected ...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Arthur Koch, 2012-03-23
@dudeonthehorse

Do not redirect, but simply give html about a non-existent page.

W
werdender, 2012-03-23
@werdender

You can watch the referrer, but not all browsers give it. You can write it in cookies before the redirect.
But I also like the option above.

S
Stdit, 2012-03-23
@Stdit

If 404 needs to be generated exactly by the backend, it is better to do something like this (nginx for example):

fastcgi_intercept_errors on;
error_page 404 /error_not_found.html;

At the same time, /error_not_found.html should give status 200. Its content will be delivered to the page at the wrong URL with status 404. The original URL will be available to php from REQUEST_URI. In this case, DOCUMENT_URI will contain /error_not_found.html.

J
jj_killer, 2012-03-23
@jj_killer

Pass as a GET parameter:404.html?from_url=/not_existed.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question