Setting up your ads.txt redirect, by platform
When you enable Connect Hosting we publish your ads.txt file at an address on our servers and hand you that address. The last step is the one thing we cannot do from here: a 301 redirect from /ads.txt on your own domain to that address. Below are the exact steps for the platforms our customers actually use, most common first.
The specification allows this deliberately. A crawler asking for https://example.com/ads.txt will follow one redirect to another domain and read the file it finds there, treating it as example.com's file. That is the whole mechanism, and it is why your file can be published without you touching your server again every time it changes.
Everything here applies to an app-ads.txt file too. Substitute /app-ads.txt for /ads.txt throughout; the Connect Hosting page always names the file the domain is for.
Before you start
- Enable Connect Hosting first, under Manage >> your domain >> Settings >> Connect Hosting. Until it is enabled the address returns a 404, and a redirect pointing at a 404 is worse than no redirect.
- Copy the Redirect To address from that page. It carries a token unique to your domain, so never reuse one from another domain or from a guide. Everywhere below it is written as
https://adstxt.guru/hosting/YOUR-TOKEN/. - The redirect has to be at the root of the domain,
/ads.txt, and it has to be a 301. A 302 works for some crawlers and not others; there is no reason to use one.
Cloudflare
Nearly half of the domains publishing through us sit behind Cloudflare, and it is the easiest case: the redirect happens at Cloudflare's edge, so nothing on your website changes, and it works even if your own server still has an old ads.txt file on it.
- In the Cloudflare dashboard pick your domain, then Rules >> Redirect Rules, then Create rule.
- Name it something you will recognise later, such as ads.txt.
- Under When incoming requests match choose Custom filter expression. Set the field to URI Path, the operator to equals, and the value to
/ads.txt. - Under Then set Type to Static, paste your address into URL, set Status code to 301, and leave Preserve query string off.
- Select Deploy.
The DNS record for your website must be Proxied, the orange cloud, rather than DNS only. On a DNS-only record the request never passes through Cloudflare, so the rule can never run. This is the single most common reason a Cloudflare redirect rule appears to do nothing.
The same reasoning applies to any other CDN or proxy in front of your site, such as Fastly, CloudFront, Akamai or Bunny: if traffic goes through it, that is where the redirect belongs, and it is usually a rules screen rather than a config file.
nginx and OpenResty
Add this to the server block for your site:
location = /ads.txt {
return 301 https://adstxt.guru/hosting/YOUR-TOKEN/;
}
Then check the configuration with nginx -t and reload with systemctl reload nginx. The = makes it an exact match, so it cannot affect any other URL on your site.
On a managed panel such as Plesk, RunCloud, Ploi or ServerPilot you will not edit the file directly. Look for a field named something like additional nginx directives or custom configuration and put the same three lines in there.
Apache, LiteSpeed and cPanel
Add this one line to the .htaccess file in the directory that would normally hold your ads.txt file, at the root of your website:
Redirect 301 /ads.txt https://adstxt.guru/hosting/YOUR-TOKEN/
It can go anywhere in the file, though if you have complex mod_rewrite rules we would put it above them. If there is no .htaccess file in that directory yet, create one with a text editor and upload it; the leading dot is part of the name.
LiteSpeed and cPanel hosting read .htaccess in exactly the same way, so this is the line for those too. OpenLiteSpeed does not read it unless it has been switched on for the site, in which case use the nginx-style rewrite in the vhost configuration instead.
Squarespace
Squarespace calls these URL mappings. Go to Settings >> Advanced >> URL Mappings, add the line below on its own line underneath anything already there, and save:
/ads.txt -> https://adstxt.guru/hosting/YOUR-TOKEN/ 301
The spacing matters: a space either side of the arrow, and the 301 at the end. If you have previously uploaded an ads.txt file to Squarespace and mapped to it, replace that mapping with this one rather than adding a second.
Wix
In your Wix dashboard go to SEO >> Tools and settings >> URL Redirect Manager, choose + New Redirect and then Single redirect. Set the old URL to /ads.txt and the new URL to your full address. It must be a single redirect: a group redirect cannot point off your own site.
If Wix will not accept /ads.txt as an old URL, it cannot redirect the file for you, and you need one of the fallbacks at the end of this page instead.
Windows Server and IIS
Add this rule inside <configuration> >> <system.webServer> >> <rewrite> >> <rules> in your site's web.config:
<rule name="ads.txt" stopProcessing="true">
<match url="^ads[.]txt$" />
<action type="Redirect" url="https://adstxt.guru/hosting/YOUR-TOKEN/" redirectType="Permanent" />
</rule>
This needs the URL Rewrite module, which most Windows hosting already has installed. If <rewrite> does not exist in your web.config yet, add it inside <system.webServer> with a <rules> element inside it.
Caddy
One line in the site block, then reload:
redir /ads.txt https://adstxt.guru/hosting/YOUR-TOKEN/ permanent
WordPress
Do not set up a redirect on a WordPress site. Install our free plugin instead: it serves your ads.txt file directly from your own domain, with no redirect and no server configuration, and it updates itself whenever your file changes here.
The exception is a WordPress site behind Cloudflare where you would rather not install anything. In that case the Cloudflare rule above works fine and never touches WordPress at all.
If your platform cannot redirect at all
Some platforms only ever serve a fixed set of files and give you nowhere to put a redirect. Blogger, Google Sites and some website builders are in this group. A redirect line will not help, and Connect Hosting is the wrong channel for you. There are three other ways to get your file published:
- Our WordPress plugin, if the site runs WordPress. See Connect WordPress.
- FTP, if you can reach the site's files. We upload the file for you every time it changes. See Connect FTP.
- Paste it in by hand. Use Download on the domain to get the file, and paste it into whatever field your platform offers. Blogger, for example, has one under Settings >> Monetization >> Enable custom ads.txt. This is the only manual option, so you have to repeat it every time your file changes, and it is the one most likely to go stale.
If your site is a static bucket (S3, Cloud Storage, Netlify, Vercel), the platform in front of it usually can redirect even though the bucket cannot. Netlify has _redirects, Vercel has vercel.json, and CloudFront in front of S3 has a function. Ask us if you are not sure which applies.
Checking it worked
Open https://example.com/ads.txt in a browser, substituting your own domain. If the redirect is in place you will land on our address and see your own file. Every file we serve starts with a comment line reading # Version, so if that line is there, the bytes came from us.
From a terminal, curl -sIL https://example.com/ads.txt shows every hop and the status code of each. You want a 301, and exactly one hop leaving your domain.
Our validator will fetch and check the file the same way a crawler does, which also tells you whether the records themselves are valid once the redirect is working.
When it does not work
These are the causes we see, in the order they are worth checking:
- The rule is not in the path the request takes. A Cloudflare rule on a DNS-only record, or an
.htaccessfile on a server that is not Apache, is configuration that is never read. This is the most common cause by a long way. - An old ads.txt file is still there and winning. On most set-ups the rules above take priority over a real file, but not on all of them. If the redirect is right and you still see an old file, delete the file.
- www and the bare domain are not both covered. Crawlers ask for whichever hostname they were given. A redirect from the bare domain to
wwwand then to us is fine, because the first hop stays inside your own domain, but a hostname that lands on a 404 is not. - You are pointing somewhere else. If
/ads.txtalready redirects to another ads.txt management service, that redirect wins and ours never runs. Only one of them can be in place at a time. - The hosting was disabled again afterwards. Our address returns a 404 whenever Connect Hosting is off for that domain, so a working redirect starts failing. If you turn Connect Hosting off, remove the redirect at the same time.
If you get stuck, please contact support with your domain name. We can see what your domain is currently serving and will tell you exactly what is happening.
Usage Documentation
- Apply one group as DIRECT or RESELLER per domain
- Collaborate
- Collaborate: Collaborator Certification
- Collaborate: Group
- Collaborate: Group: Settings
- Getting Started Guide for Ad Networks
- Getting Started Guide for Publishers
- Manage
- Manage: app-ads.txt Files
- Manage: Domain
- Manage: Domain: Settings
- Manage: Domain: Settings: Connect FTP
- Manage: Domain: Settings: Connect Hosting
- Manage: Domain: Settings: Connect WordPress
- Manage: Domain: Verify Domain
- Security: reporting a vulnerability
- Setting up your ads.txt redirect, by platform