2013-02-14 35 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