Whats the number of times the letter p appears in:
Q: Nginx proxy pass and url rewriting How to trig this rule only when I have parameters in url,
otherwise I will match on an alias.
location ~^/static/photos/.* {
    rewrite ^/static/photos/(.*)$  /DynamicPhotoQualitySwitch/photos/$1  break;
    expires     7d;
    proxy_pass http://foofoofoo.com;
    include /etc/nginx/proxy.conf;
     }


A: You could add a condition to check if the $args parameter is not empty:
location ~^/static/photos/.* {
  if ($args != ){
    rewrite ^/static/photos/(.*)$  /DynamicPhotoQualitySwitch/photos/$1  break;
    expires     7d;
    proxy_pass http://foofoofoo.com;
    include /etc/nginx/proxy.conf;
  }  
}


A: Replace the * (meaning 0 or more) to a + (meaning 1 or more)
For example, this:
location ~^/static/photos/.* {
    rewrite ^/static/photos/(.*)$  /DynamicPhotoQualitySwitch/photos/$1  break;
    expires     7d;
    proxy_pass http://foofoofoo.com;
    include /etc/nginx/proxy.conf;
}

becomes:
location ~^/static/photos/.+ {
    rewrite ^/static/photos/(.+)$  /DynamicPhotoQualitySwitch/photos/$1  break;
    expires     7d;
    proxy_pass http://foofoofoo.com;
    include /etc/nginx/proxy.conf;
}


A: Here is my answer now that I understand the question better:
Have you tried try_files?
For example it would probably look something like:
try_files /DynamicPhotoQualitySwitch/photos/$args /path/for/no/args;

location /path/for/no/args {
    expires     7d;
    proxy_pass http://foofoofoo.com;
    include /etc/nginx/proxy.conf;
}


user
In that passage, there are fifty-four occurrences of the letter "p."
assistant