title: Nignx rewrite pattern on search query?
body: <p>Its a very basic thing i need to do, but i cant figure this one out.</p>
  
  <p>i have following rule in my nginx.conf</p>
  
  <pre><code>    location ^/search {
          #try_files index.php?search=$1  last;
          rewrite ^/search/(.*)/ index.php?search=$1;
          #rewrite ^/search/([^/]+)/page/([^/]+)/?$ /index.php?search=$1&amp;page=$2;
      }
  
      location ^/article {
          rewrite ^/article/([^/]+)/([^/]+)/$ /index.php?layout=article&amp;id=$1;
      }
  
      location ^/images {
          rewrite ^/images/([^/]+)$ /images/$1 break;
          rewrite ^/images/([^/]+)/([^/]+)$ /images/$1/$2 break;
      }
  
      location ^/css {
          rewrite ^/css/([^/]+)$ /css/$1 break;
          rewrite ^/css/([^/]+)/([^/]+)$ /css/$1/$2 break;
      }
  
      location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
          root $root_path;
      }
  
      location ~ /\.ht {
          deny all;
      }
  
      location ~ \.php$ {
              try_files $uri =404;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass  127.0.0.1:9000;
              fastcgi_index index.php;
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include /etc/nginx/fastcgi_params;
      }
  </code></pre>
  
  <p>basically all i want to do is 
  match below query on search to this above.</p>
  
  <pre><code>example.com/search-term1/
  or
  example.com/search term/
  or 
  example.com/search/search-term1/
  or
  example.com/search/search-term1/page/1/
  </code></pre>
  
  <p>above url patterns ?how do i do this ? above rule gives me error 500 Internal server error.</p>
  
  <p>in the Nginx log i get following as </p>
  
  <pre><code>2015/08/05 12:56:39 [error] 11136#0: *2 could not find named location "@rewrite", client: 202.172.107.194, server: example.com, request: "GET /search/search-term1/page/1/ HTTP/1.1", host: "example.com"
  </code></pre>