0

I have setup wordpress proxy for all routes but I don't want to proxy the preview urls. The typical url looks like this. I would rather setup the proxy rule so if it contains preview=true don't proxy it.

https://www.example.com/slug/?preview_id=2028&preview_nonce=142f805c73&_thumbnail_id=-1&preview=true

This is what I have so far

location ~.*preview_id.* {
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
  • What is the preview? Is it at /slug/index.html? Also, you cannot use location to test preview_id as it's part of the query string. You could use if ($arg_preview_id) { ... } instead. – Richard Smith Dec 3 '18 at 10:08
1

preview is a GET-argument, not a part of the URI from the nginx point of view (although it may appear to you as one), so you need to check $arg_ variables, not the location.

|improve this answer|||||
  • Can you please provide a more detailed answer. I can't add if statement and check inside the location because I either get can't proxy inside if statement or try_files" directive is not allowed here in based on the way I write my if statement. – Yasin Yaqoobi Dec 3 '18 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.