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:
location ~* orderby=rand {
deny all;
}
This is very slow and consumes a resource feature of WordPress.
The location directive doesn’t match the query string at all. You need to reference the $args variable using an if statement.