title: NGINX 405 Not Allowed when uploading file
body: <p>I need to redirect all file upload request <a href="https://example.com/year2017/monthsept/upload/" rel="nofollow noreferrer">https://example.com/year2017/monthsept/upload/</a> to go to <a href="https://example.com/upload/" rel="nofollow noreferrer">https://example.com/upload/</a></p>
  
  <p>In nginx config I have the following location/rewrite rule within the server block. However, I receive 405 error.</p>
  
  <pre><code>location ~ ^/year2017/monthsept/upload/(.*) {
  rewrite ^year2017/monthsept/upload/$1 /upload/$1 permanent;
  }
  
  $ curl --verbose --upload-file test.txt https://example.com/year2017/monthsept/upload/
  </code></pre>
  
  <blockquote>
    <p>PUT /year2017/monthsept/upload/test.txt HTTP/1.1
    &lt; HTTP/1.1 405 Not Allowed
    * HTTP error before end of send, stop sending
    * Closing connection 0</p>
  </blockquote>
  
  <p>I have updated the rewrite rule so often but no joy.</p>
  
  <p>What would the correct nginx rule for this be?</p>