I’ve been asked to add an analytics.txt file to a wordpress website so I’ve created the file and uploaded it to the server document root but when I go to it via the url www.examples.com/analytics.txt
all I get is a 404 error.
I’ve checked the file permissions and I’ve cleared the wordpress cache but neither have helped.
Any ideas?
The folder structure is as follows:
wp-admin
wp-content
wp-includes
analytics.txt <-- added this file, but cannot seem to access it via a web browser
index.php
etc...
This is NOT the solution but it is a work-around while I carry on trying to figure out why wordpress won’t allow me to access my file.
So if you’re desperate and HAVE to get it sorted right now, here is what you could do, but I warn you, it’s ugly! Open your index.php file and you should see something like this:
Make a backup copy first and then add the wrapping if statement:
Like I said, this is a dirty solution but when needs must and the client is getting impatient, this could help in the mean time.
Hoping that someone will have a better solution though!
I was able to get this to work with the following for the Sage theme:
app/uploads/2018/09/analytics.txt
Open the
functions.php
file and add the following:Flush and regenerate the rewrite rules database: From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.