I have a Drupal app at the default virtual host example.org running on Debian 8. I also have a separate application with a virtual host set to send requests for jones-store.example.org to another directory. That works as expected.
I also have a CNAME of jones.example.org that should point to example.org/jones. I cannot see how that would work because the Apache virtual host is expecting to send requests for this subdomain to a physical place on the server. But as you know, Drupal is handling these routes itself.
So I started searching and believe that .htaccess should redirect this.
RewriteCond %{HTTP_HOST} ^jones\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/jones [L,R=302]
You can probably tell what's going to happen. It appears that the virtual host is checked first and the virtual host beats out the .htaccess rule.
I've tried the following rule:
RewriteCond %{HTTP_HOST}=jones.example.com [NC]
But it also catches the virtual host first.
I disabled my jones-store.example.org temporarily and the htaccess "catches" but does not redirect to the url.
But my main question is how could I do this redirect with this virtual host?