HTTP 404 On AnsPress not found pages

3.37K viewsCore
0

When question is not accessible or not found AnsPress generates 404 status and shows a 404-like page to the user. But actually, the header which is returned to the client is an HTTP 200 OK, because anspress works like a shortcode and base page output already begun.

Any idea hot to make a real 404 status if a question is not found? Also, I want to generate 404 if a question is not accessible due to ACL restrictions (e.g. private question).

commented

Hello,
Can you share link to your site so that I can see the response as well.

You can look at this as an example: https://www.lexum.co.za/question/non-existent/
The inner content of the page which tells about the error is stored in ‘not-found.php’ from anspress and is shown when anspress code makes a call to SELF::404. The other code which should change the response to 404 is intact, but still it gives a 200 OK to the client. I assume it is because page template starts output first, then it comes to anspress shortcode and only there it tries to set the status to 404 but it is already too late.

Yes, I think so. I will check this issue and release a fix.