nginx – How to seperate file and folder

    location / {
       try_files $uri /listing.php; #todo if file redirect to file_manager.php
    }

    location /YTDownload/ {
        alias /home/keegang/files/YTDownload/;
        try_files $uri /listing.php;
    }

    location ~* \.\w+$ {
        rewrite ^/(.*)$ /file_manager.php?file=$1 last;
    }

im trying to redirect user to custom file_manager.php if it is a file but

~* \.\w+$

catch everyting even foldername
i try ask ai and they give me

location ~* \.(jpg|png|pdf|txt|doc|docx)$ {

which it also redirect to file_manager.php if folder name end with .jpg.png…

Read more here: Source link