nginx - After blocking access to all txt files in WordPress, how to allow access to virtual robots.txt?
PHP中文网
PHP中文网 2017-05-16 17:09:44
0
3
697

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).

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
为情所困

Pay attention to the order

location = /robots.txt {
  rewrite ^/robots\.txt$ /index.php?robots=1 last;
  allow all;
}
Ty80

You can just allow nginx for robots.txt separately and put it above the nginx rule that prohibits all txt

習慣沉默

@南小鸟 invited to answer

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template