Ads.txt is a text file introduced by the IAB Tech Lab to help combat ad fraud and ensure transparency in digital advertising. Publishers typically upload this file to the root of their webserver (eg: /ads.txt), and it allows buyers to verify the inventory they are buying is legitimate.

In many cases, ad management companies will suggest using an HTTP Redirect to send requests for this file to a copy hosted by their ad management company.

In this article:

Why A Redirect Is Helpful

Ads.txt can be lengthy and will change frequently, even as often as multiple times per day. Publishers who host their own /ads.txt will therefor need to update the contents of this file regularly, which is time consuming and error prone.

Redirecting request for ads.txt to a hosted version means the publisher is not required to keep the contents up to date.

How Does It Work?

Your webserver receives requests from users for content and other assets, such as Images, JavaScript, and CSS (Style Sheets). Self hosting ads.txt means you upload the file “ads.txt” to the root of your website, so it’s accessible with the URI “/ads.txt”

However the IAB Ads.txt Specifications allows for a “single HTTP redirect to a destination outside the original root domain is allowed to facilitate one-hop delegation of authority to a third party’s web server domain.” Which essentially just means you can redirect “/ads.txt” from your website to a copy hosted somewhere else, such as a providers CDN.

The redirect must be an HTTP 301, 302, or 307 redirect.

How To Create Or Edit A Redirect

There are likely two places where you can manage a redirect. If you use a Content Delivery Networks (CDNs) such as CloudFlare, they often have the ability to redirect requests for assets before the request reaches your webserver. If you don’t use a CDN, then the webserver itself could return the redirection destination.

Create A New Redirect Rule in CloudFlare Rules

  1. Login to your CloudFlare account and navigate to your Domain Settings
  2. Expand “Rules” on the left side navigation, then click Overview
  3. Under the “Redirect Rules” section, click “Create rule
image
How To Set up or Edit Ads.txt Redirect 3

Enter the following settings:

  • Name = Adst.xt Redirect
  • If incoming requests match = Custom filter expression
    • URI Path Starts With /ads.txt
  • Redirect Type = Static
  • Status Code = 302
  • URL = <Destination for the redirect>

Click Deploy to save and activate the Redirect Rule.

image 1
How To Set up or Edit Ads.txt Redirect 4

Example Ads.txt Redirect with CloudFlare Redirect Rule

Edit A Redirect Rule in CloudFlare Rules

It’s possible you have existing redirects using CloudFlare’s older Page Rules instead of their new Rules system. The instructions below describe how to edit the newer Redirect Rules, but the settings are similar for Page Rules, which can be found under Rules > Page Rules in the left sidebar navigation.

  1. Login to your CloudFlare account and navigate to your Domain Settings
  2. Expand “Rules” on the left side navigation, then click Overview
    • Or click Page Rules, if using this system instead
  3. Click on the name of the rule to edit
  4. Edit the destination redirect to the URL given to you by your ad management provider
  5. Click Save

See above for a screenshot for configuring a redirect with CloudFlare Rules.

Redirect using Apache 2

If your webserver uses Apache2, you can edit .htaccess in your webroot to add (or edit) the following redirect:

RewriteEngine on
Redirect 302 /ads.txt https://cdn.adligature.com/example.com/ads.txt

Please ensure you are using the correct target destination given to you by your ad management provider.

Redirect using Nginx

If your webserver uses Nginx, you must edit the site configuration for your webserver under “/etc/nginx/sites-enabled”. Add or edit a block such as below.

location /ads.txt {
  rewrite ^/ads.txt https://cdn.adligature.com/example.com/ads.txt redirect;
}

Please ensure you are using the correct target destination given to you by your ad management provider.

Related Articles

  • Adligature: Statements

    What are Statements? The type of statement each publisher receives is based on their publisher type. Trading Platform publishers receive monthly statements that report the publisher’s accrued earnings across all of their properties. Typically this statement shows how much Adligature will pay the publisher based on their NET payment terms. Premium Publishers receive invoices which…

    Read More

  • FS Poster: Facebook First-Comment Auto-Posting

    Connect your social accounts and publish so FS Poster shares each post as a native Facebook photo with the article link in the first comment – the setup that maximizes reach.

    Read More

  • Advally WordPress Plugin

    What it is The Advally Advertising plugin is the official Adligature ad integration for WordPress sites. It is the WordPress counterpart to the XenForo 2 plugin that runs on Audiokarma, Audizine, and the other forum properties — same ad stack, same targeting model, same revenue protections, expressed in WordPress terms. In one sentence: it loads…

    Read More