title: Nginx redirect for some url (return 404)
body: <p>How to create a redirect for url returned to 404 (in cms). Use nginx+php-fmp.</p>
  
  <p>Example. There is a category /auto/ with 4 pages:</p>
  
  <ol>
  <li>/auto.html,</li>
  <li>/auto/page-2.html,</li>
  <li>/auto/page-3.html,</li>
  <li>/auto/page-4.html</li>
  </ol>
  
  <p>How for the others urls (/auto/page-5.html ... /auto/page-200.html) return 301 to /auto.html?</p>
  
  <p>This code, return 301 for all url (/auto/page-2.html, /auto/page-5.html ...). What is the error?</p>
  
  <pre><code>location ~* /(auto)/page-\d+\.html {
    error_page 404 = @page;
  }
  location @page {
    rewrite /(.*?)/page-\d+\.html http://site.ru/$1.html permanent;
  }
  error_page 404 =404       /404.html;
  location ~* \.php$          {
    include                   fastcgi_def;
  }
  location /                  {try_files $uri /index.php?$args;}
  </code></pre>