title: How do i configure nginx to redirect to a url for robots.txt & sitemap.xml
body: <p>I am running nginx 0.6.32 as a proxy front-end for couchdb. I have my robots.txt in the database, reachable as <a href="http://www.example.com/prod/_design/mydesign/robots.txt" rel="noreferrer">http://www.example.com/prod/_design/mydesign/robots.txt</a>. I also have my sitemap.xml which is dynamically generated, on a similar url.</p>
  
  <p>I have tried the following config:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>This appears to work as a redirect but is there a simpler way?</p>