Introduction to ads.txt #
All of the exchanges we run through NitroPay require a valid ads.txt file on your site. If you don’t set this up properly, you’ll be missing most if not all of the high-paying revenue opportunities that are available to you.
Per the one-hop rule in the IAB specification, it is highly recommended that you set up a 301 redirect from yourdomain.com/ads.txt to the hosted ads.txt file maintained by NitroPay. Setting up a redirect ensures that you are kept up to date to any changes and not at risk of lost revenue.
We have documentation for settings up redirects on Apache, Nginx, Cloudflare, and others.
The URL to your custom ads.txt is below, where ####
is the ID of your site which can be found in the panel.
https://api.nitropay.com/v1/ads-####.txt
Alternatively you can copy the contents of our hosted ads.txt and host it locally on your site’s ads.txt file, but this discouraged as we add new partners regularly and it will be your responsibility to update the file.
Custom entries may be added by visiting the Sites configuration on the NitroPay Panel.
Redirecting ads.txt on Apache #
This section covers basic steps on setting up a 301 redirect for Apache web servers.
- Look for the .htaccess file in the root directory of your site. If it doesn’t exist, create one.
- Add the following lines if they are not already present in the file
Options +FollowSymLinks
RewriteEngine on
- Add the following line in the file, replace #### with the ID of your property, found in your site list in the NitroPay panel.
Redirect 301 /ads.txt https://api.nitropay.com/v1/ads-####.txt
- Save the file (and deploy your website if necessary).
- Test that the redirect works by going to yourdomain.com/ads.txt and noting that the URL and contents changed to the hosted ads.txt.
Redirecting ads.txt on Nginx #
This section covers basic steps on setting up a 301 redirect for Nginx web servers.
- Locate your Nginx site configuration.On Unix this is commonly in /etc/nginx/conf/sites-enabledOn Windows look for the conf directory in the directory nginx was installed
- Open the configuration file for your website.
- Add the following line in the file, replace #### with the ID of your property, found in your site list in the NitroPay panel.
rewrite ^/ads.txt$ https://api.nitropay.com/v1/ads-####.txt permanent;
- For example, this might look like:
server {
. . .
server_name yourdomain.com www.yourdomain.com;
rewrite ^/ads.txt$ https://api.nitropay.com/v1/ads-####.txt permanent;
. . .
}
- Save the file and restart nginx.
- Test that the redirect works by going to yourdomain.com/ads.txt and noting that the URL and contents changed to the hosted ads.txt.
Redirecting ads.txt in Cloudflare #
This section covers basic steps on setting up a 301 redirect with a Cloudflare Page Rule.
- Go to your site on the Cloudflare panel and select the Page Rules tab
- Click ‘Create Page Rule’
- For the url match, enter <yourdomain>/ads.txt
- For settings, select ‘Forwarding URL’, then ‘301 – Permanent Redirect’, and the URL of your ads.txt, which can be found found in your site list in the NitroPay panel
- Finally, hit ‘Save and Deploy’
Your settings should look similar to this, but with your own domain and site id:
Redirecting ads.txt on Node.js/Express #
This section covers basic steps on setting up a 301 redirect for Node.js / Express web servers.
- Open the node.js file where your routing is commonly done.
- Add configuration similar to the follow in the file, replace #### with the ID of your property, found in your site list in the NitroPay panel.
app.get("/ads.txt", function(req, res) {
res.redirect(301, "https://api.nitropay.com/v1/ads-####.txt");
});
- Save the file and deploy your website.
- Test that the redirect works by going to yourdomain.com/ads.txt and noting that the URL and contents changed to the hosted ads.txt.
Redirecting ads.txt on Windows Servers #
This section covers basic steps on setting up a 301 redirect for Windows (IIS) web servers.
- Ensure the rewrite module is installed (see here for Microsoft’s documentation)
- Open web.config in the root of your site
- Add the following configuration in the file, replace #### with the ID of your property, found in your site list in the NitroPay panel.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="NitroPay">
<match url="ads\.txt" />
<action type="Redirect" redirectType="Permanent" url="https://api.nitropay.com/v1/ads-####.txt" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
- Save the file, build and deploy your website.
- Test that the redirect works by going to yourdomain.com/ads.txt and noting that the URL and contents changed to the hosted ads.txt.