我正在运行nginx 0.6.32作为couchdb的代理前端。我在数据库中有我的robots.txt,可以达到http://www.example.com/prod/_design/mydesign/robots.txt。我也有我的sitemap.xml是动态生成的,类似的网址。如何配置nginx重定向到robots.txt和sitemap.xml的url
我曾尝试以下配置:
server {
listen 80;
server_name example.com;
location/{
if ($request_method = DELETE) {
return 444;
}
if ($request_uri ~* "^/robots.txt") {
rewrite ^/robots.txt http://www.example.com/prod/_design/mydesign/robots.txt permanent;
}
proxy-pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
这似乎是一个重定向到工作,但有一个更简单的方法?
这看起来是最简单的解决方案,并且对我来说完美无缺。 – Gattster 2010-12-15 02:28:08