Subdomain route to subfolder with htaccess on wordpress

You have to create a virtual host in apache config.

<VirtualHost *:80>
    ServerName sub.domain.com
    DocumentRoot /var/www/sub
</VirtualHost>

Or VirtualDocumentRoot if mod_vhosts_alias is enabled.

<VirtualHost *:80>
    ServerName sub.domain.com
    ServerAlias *.domain.com
    VirtualDocumentRoot /var/www/%1
</VirtualHost>

In above I am pointing it to /sub directory if it exists. After all changes restart the server.