How can Nginx rewrite the access path of a thousand-bit directory without a thousand-bit directory through rewrite after adding the thousand-bit directory of the self-added ID?

problem description

how to rewrite the access path of a thousand-bit directory without a thousand-bit directory through rewrite after Nginx follows the thousand-bit directory of the self-incremented ID?

directory structure

/image/
    Floor(id/1000)/
        id.jpg
        
/image/
    0/
        1.jpg
        234.jpg
    123/
        123000.jpg
        123456.jpg
        123999.jpg

goal

https://img.codeshelper.com/upload/img/2021/10/14/ejvx2sf0uli135.jpg visit / image/0/234.jpg
https://img.codeshelper.com/upload/img/2021/10/14/pe4d50atgu5136.jpg visit / image/123/123456.jpg

Oct.14,2021

solve

server {
    listen       80;
    location /image/ {
        alias        /image/;
        rewrite      "^/image/(\d{1,3})\.jpg$" /image/0/$1.jpg last;
        rewrite      "^/image/(\d{1,})(\d{3})\.jpg$" /image/$1/$1$2.jpg last;
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43d06-44a63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43d06-44a63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?