How to make a search result page as a 404 when there are no results?

[ad_1]

hello.

I’ve been suffering from a massive internal site search spam attack on my site for about a year now.

They use wordpress’s search function /?s= or /search/ to link to malicious keywords and get them indexed by bots.

example.com/?s=k%EC%86%8C%EB%9D%BC%EB%84%B7%E2%86%97%20NAJA9. com%20%E2%95%84%EC%9A%B8%EC%A7%84%20%EB%A6%BD%EC%B9%B4%ED%8E%98%E3%8E%A2%EC%95%84%EC%82%B0%20%ED%9C%B4%EA%B2%8C%ED%84%B8%E2%96%A6%EB%8F%99%EB%8C%80%EB%AC%B8%20SM%EC%9B%90%EC%B8%84%E2%87%94%EC%9E%A0%EC%8B%A4%20%EC%97%AC%ED%96%89%ED%8C%8C%ED%8A%B8%EB%84%88%E2%94%8E%EC%9C%84%EB%A1%80%20%EC%95%84%EC%A3%BC%EB%A7%88%EB%A7%8C%EB%82%A8%E2%95%83

The Blocksy theme currently shows an HTTP response code of 200 when there are no search results, is there any way to change this to 404?

I would like to change it to 404 when there are no matching search results and 200 when there are.

Thanks.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer