Skip to content

Commit

Permalink
Set response code for ads.txt requests
Browse files Browse the repository at this point in the history
Under some configurations, the web server will set a status code of 404 for requests to domain.com/ads.txt since the physical file cannot be present for WordAds to return an automatically generated ads.txt. When the generated response is sent, no response code was set so the previous 404 is used. This will cause crawlers such as Google's to ignore the response and the file will be considered non-existent.

Fixes #14169
  • Loading branch information
Beau Hastings authored Dec 4, 2019
1 parent 8e65975 commit 1867240
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions modules/wordads/wordads.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function init() {
*/
$ads_txt_content = apply_filters( 'wordads_ads_txt', $ads_txt_transient );

http_response_code( 200 );
header( 'Content-Type: text/plain; charset=utf-8' );
echo esc_html( $ads_txt_content );
die();
Expand Down

0 comments on commit 1867240

Please sign in to comment.