I
I
Ivan Kozlov2015-12-30 09:00:38
HTTP headers
Ivan Kozlov, 2015-12-30 09:00:38

Site on wordpress. How to manually change the page return code from 404 to 200?

Redesigned a website for a client. Before that, there was a site on a self-written system, I transferred it to wordpress. In order to keep the same url as on the old site, I had to add some crutches. The new version of the site has pages (urls) on which the server returns a 404 error code, although the records exist (this is just the moment of my crutches). It is necessary to display the response code 200 on these pages. In the header of the topic, I intercept these pages. Those. there are conditions that would run some function to set the response code 200.
How to put a 200 response on wordpress ??
status_header(200) - did not help
header("HTTP/1.1 200 OK") - did not help

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Kozlov, 2016-03-30
@trampick

I found how to do it:
in the wp-includes/functions.php file in the function
Add a condition that checks whether the url is necessary and if so, issue
@header('HTTP/1.1 200 OK');

X
X-, 2015-12-30
NoNAME @XNoNAME

There is a plugin that returns the most appropriate entry with the 200 code on 404, you can see how they do it in its source code.
Permalink Finder

P
Puma Thailand, 2015-12-30
@opium

It is necessary to make the right crutch in the form of a redirect and not to fence such shit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question