0

I can not access my uploaded .txt in Wordpress, it gives a 403 access denied error. I can access .png files however, why not .txt files?

I uploaded my file here:

enter image description here

And got the URL here (I click copy, go in incognito mode, paste it and get the 403 error):

enter image description here

4
  • if you visit a file directly it's not WordPress serving it but the host itself aka Apache/Nginx. It's very likely this is your hosts security software or a HTAccess rule and nothing to do with WordPress
    – Tom J Nowell
    Feb 9 at 19:21
  • @TomJNowell No it's related to Wordpress, I bought a domain just through wordpress and they host everything. What is the problem by just showing the .txt? How can I make sure other people can just download the .txt? It looks so hard for such a simple task. I don't know anything about HTAccess rules, Apache/Nginx. Why is uploading/downloading a simple .txt so hard in Wordpress?
    – NoKey
    Feb 9 at 22:03
  • 1
    Ah do you mean wordpress.com? This stack is for WordPress the open source PHP software, not the 3rd party commercial hosting service WordPress.com ran by Automattic. WordPress is just the PHP application that runs on the host, WordPress itself won't be serving those text files, your host will be ( in your specific case it seems both the software and the host have almost the same name, and it'll be an Nginx server from what I understand of WordPress.com's services ).
    – Tom J Nowell
    Feb 12 at 15:23
  • This will help avoid confusion in the future: wordpress.com/support/com-vs-org and wordpress.org/documentation/article/…, when you see people talking about code they're almost always talking about .org, not .com. WordPress.com works a little differently and can have quirks, restrictions, as well as features you wouldn't normally find elsewhere without installing a plugin ( usually via Jetpack )
    – Tom J Nowell
    Feb 12 at 15:24

1 Answer 1

0

WordPress isn't doing this, those files are served by the server underneath WordPress, aka Nginx/Apache/etc. This is because there's a cost to loading WordPress and you don't want to pay that cost for assets such as JPEG's or other files in the uploads folder, it's much faster to let Apache/Nginx do it as that's something they've been optimised for.

why not .txt files?

Because you're a WordPress.com customer:

enter image description here

WP.com has configured their servers not to serve plaintext files as a security measure.

Is WordPress.com not WordPress?

No, WP.com is a 3rd party host that hosts WordPress sites. Its main differentiator is that it has access to the trademarks and is ran by the founder, but the software it runs isn't quite the same as what everybody else is running.

WordPress.com has a lot of additional restrictions, features, and quirks intended to make it more secure and scale better. Partially because it used to be one gigantic multisite installation. One of these differences will be stopping displaying arbitrary text files which could be used for malicious purposes.

Most WordPress sites do not run on WordPress.com

Resolving This

You'll need to speak with their support to resolve this, though there's a high chance they'll say that it is not possible. Moving to an alternate host is also an option.

E.g. I was able to upload and serve a plaintext file on my host (a VPS):

https://tomjn.com/wp-content/uploads/2024/02/wordpress-text-files.txt

The edge case

For completeness sake should someone else be reading this, the one scenario where WordPress does serve these files is ms-files.php. If your direct URL to the text file references ms-files.php then WordPress is responsible, however this requires that you have multisite setup, and have configured WordPress to use this file.

In the case of a WordPress.com site, this is extremely unlikely, and virtually impossible on anything newer than 10 years old. If you do not see ms-files.php in the URL then this is not happening.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.