nginx多才多艺的重写规则

I have the needs for a rewrite rule for this cases

mydomain.com/?epunique=XXXX-XXXX-XX-XXXX-XX&epshare=fbtw&time=201905018

i want to make my urls looks like

mydomain.com/XXXX-XXXX-XX-XXXX-XX/fbtw/201905018

or

mydomain.com/site/XXXX-XXXX-XX-XXXX-XX/fbtw/201905018

XXX can be any char even a file name

mydomain.com/account.php or mydomain.com/upload.php

after many tries this what i got but dont work

location = /site/(.+)/(.+)/(.+) {
   rewrite ^site/(.+)/(.+)/(.+)/?$ index.php?epunique=$1&epshare=$2&time=$3 last; 
}

this is my nginx version

nginx-1.12.2_11,2

UPDATE 05-29-2019

I got this working partially

location / {
            try_files $uri $uri.html $uri/ @extensionless-php;
                index index.html index.htm index.php;

                # reglas para urls limpias
                rewrite ^/(upload|upload_pago|desktopmap|upload_cat|refresh)/?$ /$1.php last;
                rewrite ^/(account|faq|planes|privacidad|nosotros)/?$ /$1.php last;
                rewrite ^/busca-por-mi/? /index.php?keywords=buscaxmi last;
                rewrite ^/empleos/? /index.php?category=empleo last;
                rewrite ^/buscar/(.+)/? /index.php?keywords=$1 last;
                rewrite ^/categoria/(.+)/? /index.php?category=$1 last;
                rewrite ^/subcategoria/(.+)/? /index.php?scategory=$1 last;
                rewrite ^/subsubcategoria/(.+)/? /index.php?sscategory=$1 last;
                rewrite ^/(.+)/(.+)/(.+)/?$ /index.php?epunique=$1&epshare=$2&ogpupd=$3 last;
                rewrite ^/(.+)/(.+)/?$ /index.php?epunique=$1&epshare=$2 last;
                rewrite ^/(.+)/?$ /index.php?epunique=$1 last;

        }
            location /(js|media|css|xajax)/{

            }

But now the server sends error message to browser

Refused to execute script from 'mydomain.com/js/swiper.min.js?v=190529102248' because its MIME type ('text/html') is not executable

i have another more js files in same location but only this fails, if i comment the rewrite rules the js and css files works as expected