Nginx: deny ‘orderby=rand’ wordpress url

I want to block url ‘http://example.com/?orderby=rand‘ on my websites by nginx.

I thought it’ll be easy (like i’ve blocked ‘wp-admin’ section). But this code doesn’t work, and i don’t know why:

Read More
location ~* orderby=rand {
    deny all;
}

This is very slow and consumes a resource feature of WordPress.

Related posts

Leave a Reply

1 comment

  1. The location directive doesn’t match the query string at all. You need to reference the $args variable using an if statement.

    if ($args ~ orderby=rand) {
       #action
    }