Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The 1st way that I know of is using a regex against the $args parameter like so:</p> <pre><code> if ($args ~ "^(\w+)=") { </code></pre> <p>Or the 2nd way is to use the convenient $is_args like so:</p> <pre><code> if ($is_args != "") { </code></pre> <p><em>Remember that in <strong>both</strong> styles you need to put a space between the if and the opening parenthesis; "if (" not "if(" as well as a space after the closing parenthesis and the opening brace; ") {" rather than "){".</em></p> <p>Full example using the 1st style above, nginx.conf:</p> <pre><code>location ~^/static/photos/.* { include /etc/nginx/proxy.conf; if ($args ~ "^(\w+)=") { rewrite ^/static/photos/(.*)$ /DynamicPhotoQualitySwitch/photos/$1 break; expires 7d; proxy_pass http://foofoofoo.com; } } </code></pre> <p>Full example using the 2nd style above, nginx.conf:</p> <pre><code>location ~^/static/photos/.* { include /etc/nginx/proxy.conf; if ($is_args != "") { rewrite ^/static/photos/(.*)$ /DynamicPhotoQualitySwitch/photos/$1 break; expires 7d; proxy_pass http://foofoofoo.com; } } </code></pre> <p>Note that the proxy.conf include goes outside of the if statement.</p> <p>Version:</p> <pre><code>[nginx@hip1 ~]$ nginx -v nginx version: nginx/1.2.6 </code></pre> <p>And some info on the $args and $is_args variables:</p> <p><a href="http://nginx.org/en/docs/http/ngx_http_core_module.html">http://nginx.org/en/docs/http/ngx_http_core_module.html</a></p> <p>Reading the docs is always useful, I just discovered that $query_string is the same as $args, so where I have $args above, you could also use $query_string according to the docs.</p> <p><strong>IMPORTANT</strong></p> <p>It is important to note however, that <a href="http://wiki.nginx.org/IfIsEvil">If can be Evil!</a></p> <p>And therefore either <em>test thoroughly</em> or use the recommendation provided in the link above to change the URL inside location statement in a way similar to the example provided there, something like:</p> <pre><code> location ~^/static/photos/.* { error_page 418 = @dynamicphotos; recursive_error_pages on; if ($is_args != "") { return 418; } # Your default, if no query parameters exist: ... } location @dynamicphotos { # If query parameters are present: rewrite ^/static/photos/(.*)$ /DynamicPhotoQualitySwitch/photos/$1 break; expires 7d; include /etc/nginx/proxy.conf; proxy_pass http://foofoofoo.com; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload