Make WordPress Core


Ignore:
Timestamp:
06/16/2016 02:58:28 PM (9 years ago)
Author:
rachelbaker
Message:

REST API: Include X-Robots-Tag: noindex header in REST API responses to prevent endpoints from being indexed by search engines.

Prevent duplicate content issues with search engines and REST API endpoint response data.

Fixes #36390.
Props m_uysl for the initial patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r37163 r37726  
    718718    }
    719719
     720    public function test_x_robot_tag_header_on_requests() {
     721        $request = new WP_REST_Request( 'GET', '/', array() );
     722
     723        $result = $this->server->serve_request('/');
     724        $headers = $this->server->sent_headers;
     725
     726        $this->assertEquals( 'noindex', $headers['X-Robots-Tag'] );
     727    }
     728
    720729    public function test_nocache_headers_on_authenticated_requests() {
    721730        $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
Note: See TracChangeset for help on using the changeset viewer.