Update: I've been through many pages of Google and I FINALLY found it! Here is the code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/%1 [L,R=302]
However, files are no longer accessible. So random.example.com does go to...