To rewrite subdomain urls internally to subdirectories under the root, ensure mod_rewrite is installed in Apache. Configure .htaccess inside the root directory as follows:-
RewriteEngine OnRewriteCond %{HTTP_HOST} !^www\.mydomain.comRewriteCond %{HTTP_HOST} ([^.]+)\.mydomain.comRewriteRule ^(.*)$ /home/sites/mydomain.com/public_html/%1/index.html
Obviously replace “mydomain” and change the path on the last line to where your website physically resides on the server. Use the variable %1 to use the name of the subdomain as the name of the destination subdirectory.