Trying to add a file to the theme root directory but always add slash when request

Hi, I’m using ghost 2.19.3. Let’s suppose my domain is I am trying to add ads.txt to the root directory, like I add this file to the root directory of the theme as well as another file ad.txt. After restart ghost, I can get ad.txt by visiting but can’t get ads.txt by example.txt/ads.txt which will be redirected to example.txt/ads.txt/. The only difference is before I restarted ghost, I tried to access ads.txt but not ad.txt.

I tried to clear my browser’s cache and retrieve the file from my server. example.txt/ads.txt will always be 301 redirected to example.txt/ads.txt/. And even there is no CDN, the same thing happens again.

I wonder if there’s any way to clear ghost itself’s cache? Or if there’s is any other way to solve this issue.

301s aren’t cached by Ghost but will be heavily cached by your browser. If you are using Chrome then you can open Web Inspector and disable the cache when browsing whilst it’s open, alternatively you’ll need to perform a full cache clear

Thanks for your prompt reply, Kevin. Even thought I cleared the cache or disable the cache, the same thing happens again. I tried to use wget on the server. I get following results as well.

HTTP request sent, awaiting response... 301 Moved Permanently Location: /ads.txt/ [following]

Hmm, can you share the ls -al output from your current theme directory? Maybe there’s a permissions problem :thinking:

I tried to change my existing ads.txt to another name and then can be accessed. I don’t think it’s a permission problem.

Do you have a proxy or cache in front of Ghost (nginx/apache/cloudflare/etc)? Is it possible the 301 has been cached there?

Hi Kevin,
Thanks for your reply. I also thought this is Nginx problem. At the same time, I encountered another problem after resolving that this one is resolved too.

How’d you end up resolving this issue? I’m having the same issue as well. Thanks!

Are you using any proxy, like Nginx, cloudflare?

Nginx, I’m running Ghost on an Ubuntu 18 image from Digital Ocean.

@Thomas_Hundley just to confirm, you are placing your files in your theme’s root directory, not Ghost’s root directory? (I realise the topic title could be a little confusing on that point!)

Yeah, as @Kevin says, you are supposed to upload these file to your theme’s root directory. If you did so, kindly check if your nginx cached this redirection. You can clear the corresponding nginx cache or delete current nginx proxy and restart a new one.

I’m having same problem. Google Adsense now requires me to put an ads.txt file in the root htdocs folder. It won’t work for me.

@chovy where are you putting the file? As mentioned above you need to add it to your theme’s folder, there is typically no “htdocs” when using Ghost


I need to place the ads.txt file at the root of a Ghost installation, but without much success.

Currently I use Ghost on a server of my own, with Nginx + Varnish and the installation made with Ghost-Cli, although I don’t have many problems, this file is taking my patience :rofl:

I read this article:

Where @Kevin replied that placing the file at the root of the theme would resolve and Ghost would map the url to the file, but that’s not the case, ghost redirects to a 404 error URL when I try to access the file at

If anyone can help with solutions on how to put this file in the root of the site I appreciate it :slightly_smiling_face:

Note: Customizing Nginx to display this file is a solution, but I would like to know how to do this internally in CMS without changing the web server.

Wash L.

@f1sc4ll ^ goes for nginx and varnish too, you’ll need to restart and/or clear the relevant caches at that level as well as your browser.

To be sure, you can try curl to fetch the file directly from your Ghost instance on your server, bypassing nginx and varnish, eg:

curl -v -H "X-Forwarded-Proto: https" ""

If the curl response is showing the file then that points to a caching problem outside of Ghost.

However, if you still see a 301 redirect then you should check that the ads.txt file is definitely located in your active theme’s root and that it has the correct permissions/ownership for Ghost to access it. If you’ve created the file manually on the server rather than via uploading the theme in the admin UI then you should restart your Ghost instance.

@Kevin Regarding the cache I already analyzed all the possibilities and eliminated this possibility of problem.

Regarding the permissions part I also thought so, but even adjusting the permissions with the other files, the problem persists.

Regarding your command suggestion to check the status of the url, below is the result:

About to connect() to port 2374 (#0)
Connected to ( port 2374 (#0)
GET /ads.txt HTTP/1.1
User-Agent: curl/7.29.0
Accept: /
X-Forwarded-Proto: https

HTTP/1.1 301 Moved Permanently
X-Powered-By: Express
Cache-Control: public, max-age=31536000
Location: /ads.txt/
Date: Thu, 01 Aug 2019 15:15:46 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Connection #0 to host left intact

Regarding the cache I already analyzed all the possibilities and eliminated this possibility of problem.

Regarding the permissions part I also thought so, but even adjusting the permissions with the other files, the problem persists.

Regarding your command suggestion to check the status of the url, below is the result:

I checked all the possible issues:

  • Cache - Clean, Checked, and OK
  • Ghost Permissions - Set, Checked, and OK
  • File Location - Checked and OK

Redirect 301 continues to as in the log above…the curious part of this story begins now…

I created other files with any-name.txt in the root of the theme, and they worked normally.

I did the test by creating a redirect inside Ghost from url to and the redirection worked normally.

Removing redirect, the initial error returns, so I can only assume there is something internal error in Ghost that is blocking the use of the url directly in the file.

@Kevin any idea what it might be?

@f1sc4ll can you share the ls -al output from your theme’s root?

@Kevin Of course, follow the log…

[root@d1 nurui]# ls -al
total 80
drwxr-xr-x 5 ghost ghost 4096 Aug  1 11:54 .
drwxrwxr-x 3 ghost ghost 4096 Aug  1 11:02 ..
-rw-r--r-- 1 ghost ghost   58 Aug  1 11:02 adss.txt
drwxr-xr-x 4 ghost ghost 4096 Aug  1 11:02 assets
-rw-r--r-- 1 ghost ghost  842 Aug  1 11:02 author.hbs
-rw-r--r-- 1 ghost ghost 1587 Aug  1 11:02 custom-authors.hbs
-rw-r--r-- 1 ghost ghost 4850 Aug  1 11:02 custom-contact.hbs
-rw-r--r-- 1 ghost ghost 1409 Aug  1 11:02 custom-tags.hbs
-rw-r--r-- 1 ghost ghost 1455 Aug  1 11:02 default.hbs
-rw-r--r-- 1 ghost ghost 1328 Aug  1 11:02 error.hbs
-rw-r--r-- 1 ghost ghost  107 Aug  1 11:02 index.hbs
drwxr-xr-x 2 ghost ghost 4096 Aug  1 11:02 locales
-rw-r--r-- 1 ghost ghost  331 Aug  1 11:02 package.json
-rw-r--r-- 1 ghost ghost  300 Aug  1 11:02 page.hbs
drwxr-xr-x 3 ghost ghost 4096 Aug  1 11:02 partials
-rw-r--r-- 1 ghost ghost  452 Aug  1 11:02 post.hbs
-rw-r--r-- 1 ghost ghost 5064 Aug  1 11:02 subscribe.hbs
-rw-r--r-- 1 ghost ghost  512 Aug  1 11:02 tag.hbs
[root@d1 nurui]#

@f1sc4ll you have no ads.txt file there, only adss.txt, I’m assuming from the redirect test you tried? Can you put it back to ads.txt and remove all related redirects?

There’s definitely nothing in Ghost itself that is causing problems, as shown above others have it working fine once they put the file in the correct place, and I’ve verified both locally and on a hosted instance that ads.txt can be served by Ghost without issue. That leaves something in your environment so it would be good to work out what that is unless you’re happy using a workaround like your ads.txt->adss.txt redirect.