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).
为情所困2017-05-16 17:11:44
Pay attention to the order
location = /robots.txt {
rewrite ^/robots\.txt$ /index.php?robots=1 last;
allow all;
}
PHP中文网2017-05-16 17:11:44
You can just allow nginx for robots.txt separately and put it above the nginx rule that prohibits all txt