Redirect URL to URL with port

Hi to all. I want to ask if MikroTik can somehow redirect the URL to the port?

For example: I have a public IP and I want access to my LAN from WAN… MikroTik to redirect me to www.domain.tld:300 after entering the URL abc.domain.tld
After entering def.domain.tld at www.domain.tld:10000 and so on.

Can MikroTik do this? If so, how can I set this up?

Mikrotik can not listen and route on HTTP Headers. The general consensus to do such things is to host a small webserver behind the mikrotik that 80,443 is forwarded to, and that server itself either reverse proxies to the internal resource, or has a redirect with the correct port number.

This ‘may’ be possible purely in-router in future by using the current beta Docker component, where you could host said small webserver on the mikrotik itself. In the mean time, something as small as a Raspberry Pi could do this job with no issue.