How to move wordpress to subdomain, keeping only .htaccess and/OR index.php in root domain?

I would like to move all files & folders of the root directory to the subdomain & keep the root directory empty with only the .htaccess file or index.php

I tried to search a lot but fail to get the solution. Only one I got it but that is also not completely working.

https://totalwebsecuritypro.com/moving-wordpress-to-new-subdomain-or-directory/

It is working perfectly if I will move to the subdirectory, which is also mentioned on wordpress.org but moving to the subdomain is missing.

On this site – Frontpage is working perfectly but the link to the other posts are not working well.