How To Edit Ads.txt Redirect

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 […]

Last Updated April 14th, 2025

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

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.

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

Advertisers and Ad Networks Partnership

If you are an SSP or Advertiser, we’d love to hear from you. Make sure to send us all relevant information about your Advertising Demand, so we can both save some time and get this set up quickly!

Read More

Site review

We offer publishers a free, no-obligation site review. As part of the review, we will look at both your ad layout and technical set-up to ensure you are not missing out on any revenue.

Read More

Working with Advally

FAQ for questions about becoming one of our clients

Read More