Introduction:
WordPress under Nginx
Nginx is set to prohibit access to all txt (method)
If you use a real robots.txt file, the above method is effective, but the website uses WordPress. A virtual robots.txt file is used. The above method causes the virtual robots.txt to be inaccessible.
How to set up nginx so that the virtual robots.txt file can be accessed?
or
Limit the path of the txt file with restricted access to the following 2 directories.
WordPress plug-in directory (/wp-content/plugins)
WordPress theme directory (/wp-content/themes).
Pay attention to the order
You can just allow nginx for robots.txt separately and put it above the nginx rule that prohibits all txt
@南小鸟 invited to answer