Last active
March 25, 2024 07:55
-
-
Save MaxLazar/80520b499c40ec71fde55ae69b11c474 to your computer and use it in GitHub Desktop.
Serve robots.txt inline in Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serve robots.txt inline in Nginx | |
06/18/2015 nginx 3 Comments | |
To quickly serve a robots.txt from Nginx without actually having access to the physical file you can define the content of the robots.txt file in the Nginx .conf file. | |
Allow access to all User-agents: | |
location /robots.txt {return 200 "User-agent: *\nDisallow:\n";} | |
Disallow access to every User-agent: | |
location /robots.txt {return 200 "User-agent: *\nDisallow: /\n";} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo on line 7: Change
Disallow
toAllow
Also can be done on multiple lines: