Ads.txt - redirects - not found

Hi Guys!

Google AdSense requires a txt file (ads.txt). It is a simple .txt file like that:, pub-0000000000000000, DIRECT, f08c47fec0942fa0

The Google looks for: to get it.

In my website it is working well in development, I mean in http://localhost:3000/ads.txt shows, pub-0000000000000000, DIRECT, f08c47fec0942fa0 (see image)


However in production, I mean (in my case) it was downloading a txt file, and the content of the txt file was my index.html.

It was happening because of the redirects:


All paths are redirected to index.html is a common configuration in SPAs (Single Page Applications) to handle routing. This rule was causing the problem when I was trying to access the ads.txt file.

So, I update the _redirects to allow access to ads.txt without redirection:


But now I’m getting Not Found Page for myDomain/ads.txt (in my case


it’s possible that the server is still interpreting the /ads.txt request as a route handled by the SPA and is unable to locate the actual file.

Any ideas on how to allow ads.txt to be accessed?

@VonSouza This redirect /* /index.html 200 doesn’t mean "all paths are redirected to index.html.

See the documentation for Shadowing, it will only redirect paths that don’t have a corresponding file.

The fact that the index.html file is being returned for that path indicates that the ads.txt file doesn’t exist in your Publish directory. Which is also confirmed by the other rule that you tried /ads.txt /ads.txt 200, as it cannot return a file it doesn’t have.

You should try running your Build command locally (not your Develop command), then check the build output in the folder that is your Publish directory (E.g. whatever folder your site builds into).

You will almost certainly find that the ads.txt file is not there, and thus not being deployed to Netlify.

You’ll then just need to adjust your build so that the file does end up in the build output.

Some build systems use a public folder for this, or you can otherwise move the file in there yourself post build.

Wow! You are totally correct @nathanmartin

The ads.txt was not in the publish directory. In my case, after running the build the ads.txt should be in dist folder, it was not there. After I put it in the public directory, the build was able to send it to dist folder. Thank you very much.