File: /storage/v4513/nginx/ivenusin-php.conf
set $has_args '';
set_by_lua $request_uri_without_args 'return string.gsub(ngx.var.request_uri, "?.*", "")';
set_by_lua $cleaned_args '
local whitelist = { "relatedposts" ,"wp-json", "p", "q", "s", "wc-api", "wc-ajax" }
local args, err = ngx.req.get_uri_args()
local c_args = {}
for arg, arg_value in pairs(args) do
for _, whitelisted_arg in ipairs(whitelist) do
if arg == whitelisted_arg then
if type(args[whitelisted_arg]) ~= "boolean" then
table.insert(c_args, arg .. "=" .. args[whitelisted_arg])
ngx.var.has_args = "?"
else
table.insert(c_args, arg)
ngx.var.has_args = "?"
end
end
end
end
return table.concat(c_args, "&")
';
set $key "nginx-cache:https$request_method$host$request_uri_without_args$has_args$cleaned_args";
#START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# END Nginx Rewrites for Rank Math Sitemaps