2013-02-14 62 views
0

我在Ubuntu服务器12.04上运行Nginx 1.1.19,并且在执行Googlebot时遇到问题,请参阅robots.txt文件。我用例子this post,但我没有得到成功。为了测试服务,我访问网站管理员工具,点击“完整性>按Googlebot搜索”...只是我从“未找到”,“无法使用网页”和“robots.txt文件无法访问” ....Nginx块robots.txt文件

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

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

# Reescreve as URLs. 
location/{ 
    try_files $uri $uri/ /index.php; 
} 

回答

0

查看我的回答here

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

2

我设法通过添加命令“rewrite”策略服务器来解决我的问题,如下面的代码。之后,我回到Google网站管理员处,使用Googlebot重新搜索,并且它工作。借此机会离开这里我的代码,将重定向端口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