I am using a VM and it works great with localhost and any subdomain. I'm also using the self-signed certificates you see in my application's general code. Locally I should be able to write something.localhost and redirect to other.localhost. To go from http to https or from non-www to www I do this and it works great, even without a real certificate.
On the real server I will have something.site.abc and redirect from something.site.xyz to something.site.abc. When I delete the DNS of something.site.xyz from the provider I would like something.site.abc (end site) to keep working.