T
T
teodor-conrad2015-03-16 15:14:57
PHP
teodor-conrad, 2015-03-16 15:14:57

What does this piece of code in the WordPress header do?

Greetings. I took a WordPress site for maintenance as a webmaster and found a piece of code in the header that was not quite clear to me. What exactly is he telling search engine robots? Thanks for your attention
The code itself:

<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'google' ) !== false )
{
    switch(rand(1,2)) 
   {
        case 1:
          header("Status: 404 Not Found"); break;
        case 2:
          Header("HTTP/1.0 200 OK"); break;
    }
    
}

if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'yandex' ) !== false )
{
    switch(rand(1,2)) 
   {
        case 1:
          header("Status: 404 Not Found"); break;
        case 2:
          Header("HTTP/1.0 200 OK"); break;
    }
    
}

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Nikolaev, 2015-03-16
@Heian

This code returns statuses 404 \ 200 randomly to search engines. IMHO, it's hard to imagine more maliciousness - in fact, for search engines, it looks like a constantly falling site.
I am not a SEO specialist, so experts may disagree with me in this opinion, but this code should not be there .

O
OnYourLips, 2015-03-16
@OnYourLips

This is a developer bookmark, malicious code.

P
Philipp, 2015-03-16
@zoonman

This is the so-called "protection" against overloading the site with indexing robots.
It’s just that the person didn’t know about the Crawl-delay directive in robots.txt and nagovnokodil.
Just remove this code, as it can cause all pages to drop out of the index with a 50% chance.
In fact, this code returns a 404 header (page not found) for Google and Yandex search robots. There are about a thousand more different worms that can walk around the site, but the author's qualifications are not enough to detect them.

G
Gluck Virtualen, 2015-03-18
@gluck59

Whoever maintained the site before you did so in order to be contacted (and paid) for SEO later.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question