How do I redirect a path as a subdomain

I need to redirect one of my subpaths as subdomain. What I mean is:

example.com/imgsrv/imgdir/img.png    ->     imgsrv.example.com/imgdir/img.png

I have set up nginx proxy pass to match the subdomain to the folder and now if I go to imgsrv.example.com/imgdir/img.png - it works. But I want the other URL to automatically redirect. I was looking at Cloudflare redirects section, but I am lost as I am new to the platform.

How can I add this redirect?

Well, that should work, shouldn’t it?

example.com/imgsrv/* -> https://imgsrv.example.com/$1

Yes, but How do I put it up in the redirects section of Cloudflare?

https://dash.cloudflare.com/?to=/:account/:zone/rules

Nevermind, I was able to do in nginx:

location ^~ /imgsrv {
    rewrite ^/imgsrv/?(.*)$ https://imgsrv.example.com/$1 permanent;
}

Thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.