Home  >  Q&A  >  body text

wordpress - Access to txt is prohibited in Nginx, with the exception of the robots.txt file. How to write the rules?

Attached are the current code rules, which prohibit access to language pack files and text files in WordPress, but also prohibit access to the website’s important robots.txt file. Although WordPress virtual robots.txt is used, It is also inaccessible. Can the Nginx master please give me some advice on how to write a judgment to exclude the robots.txt file?

  location ~* ^.+\.(po|mo|txt)$ {
      return 403;
  }
某草草某草草2713 days ago794

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:11:54

    location ~* (\.txt)$ {
        location ~ robots\.txt$ {
        allow all;
        }
    deny all;
    }

    reply
    0
  • Cancelreply