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

  • 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

  • Using 1Password with Advally (sharing access securely)

    We never send passwords by email, text, or chat. Advally shares logins and credentials with you — and collects the access we need to set things up — through 1Password, a secure shared vault. It works both ways and takes about five minutes to set up. 1. Accept your invitation You’ll get an email invite…

    Read More

  • Advally XenForo 2 Plugin: Beta Feedback Widget

    The Beta Feedback Widget is a floating feedback button built into the Advally XenForo plugin for Advally WebOps publishers only. It allows trusted forum users (typically admins and moderators) to submit feedback about the plugin directly from the live forum, creating a ticket in the Advally WebOps support queue. The widget only appears on sites…

    Read More