title: Nginx redirect using return 301
body: <p>I need to do permanent redirect from URLs:</p>
  
  <pre><code>https://SiteName.com/shop/forklift-tires/XXX/
  to
  https://SiteName.com/shop/tires/forklift-tires/XXX/
  </code></pre>
  
  <p>or</p>
  
  <pre><code>https://SiteName.com/shop/forklift-tires/YYY/
  to
  https://SiteName.com/shop/tires/forklift-tires/YYY/
  </code></pre>
  
  <p>How could I do it using structure below?</p>
  
  <pre><code>location *something* {
          return 301 *something*;
  }
  </code></pre>
  
  <p>As I understood from article <a href="https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites" rel="nofollow noreferrer">"Pitfalls and Common Mistakes"</a> it`s best to use <strong>return</strong> instead of <strong>rewrite</strong>.</p>