Nginx block robots.txt文件

Nginx block robots.txt文件,nginx,robots.txt,Nginx,Robots.txt,我在Ubuntu服务器12.04上运行Nginx 1.1.19,在使用Google机器人时遇到问题,请参阅robots.txt文件。我用了这些例子,但没有成功。为了测试这项服务,我访问网站管理员工具,点击“Integrity>SearchasGooglebot”。。。只是我收到了来自“未找到”、“页面不可用”和“robots.txt文件不可访问”的消息 我还要确认是否应该对文件nginx.conf或/etc/nginx/sites enabled中的文件“default”执行配置,因为在以后的版

我在Ubuntu服务器12.04上运行Nginx 1.1.19,在使用Google机器人时遇到问题,请参阅robots.txt文件。我用了这些例子,但没有成功。为了测试这项服务,我访问网站管理员工具,点击“Integrity>SearchasGooglebot”。。。只是我收到了来自“未找到”、“页面不可用”和“robots.txt文件不可访问”的消息

我还要确认是否应该对文件
nginx.conf
/etc/nginx/sites enabled
中的文件“default”执行配置,因为在以后的版本中,我注意到可能会有所不同。 这是我的基本设置

root /usr/share/nginx/www;
index index.php;

# Reescreve as URLs.
location / {
    try_files $uri $uri/ /index.php;
}
看看我的答案


关于将它添加到主
nginx.conf
文件或可用的
/etc/nginx/sites
文件中,这取决于您,您希望它分别是全局的还是特定于站点的。

我通过添加命令“重写”策略服务器来解决我的问题,如下代码所示。在那之后,我回到谷歌网站管理员那里,用谷歌机器人重新编辑搜索结果,结果成功了。借此机会将我的代码留在这里,它将端口80重定向到443前缀,将非www重定向到www

# Redirect HTTP to HTTPS and NON-WWW to WWW
server {
    listen 80;
    server_name domain.com.br;
    rewrite ^ https://www.domain.com.br$1 permanent;

# Rewrite the URLs.
    location / {
    try_files $uri $uri/ /index.php;
    }
}
server {
    listen 443;
    server_name www.domain.com.br;

# Rewrite the URLs.
    location / {
    try_files $uri $uri/ /index.php;
}

    root /usr/share/nginx/www;
    index index.php;

    [...] the code continued here