Self hosted (shared server) htaccess Q

many moons ago i got emoncms up and running on a shared server and it has been runnign fine since. only need to do an git pull a few times a year

i list the link to install instructions and i can see they have been updated

the old instructions told to add this bit to htaccess

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RedirectMatch ^/$ /emoncms/

so that it would jump to the sub folder even if it was not entered

now i want to create a subdomain for some testing and of course even the subdomain shows the emoncms server

the path is /var/www/public_html/emoncms and /var/www/test for the subdomain with the htaccess placed in /var/www/public_html…

also in the root it a folder named emoncmsdata

how can i get the effect of people going to main domain (example.com for this post) still gets sent to the emoncms folder but people that goes to test.example.com does not get redirected?

I think Google is your friend here, for a way into the Apache documentation. I know Rewrite is very powerful, and I seem to think I’ve done something like that in the past, but I wouldn’t be able to remember the details now anyway.

so far my list of friends to not include google hence the post

but will post the answer should i be lucky

It’s your lucky day - I am feeling benevolent:

https://www.thesitewizard.com/apache/redirect-domain-www-subdomain.shtml

You might need to look up the meaning of the Regex expressions to see how and why it works.

i was here: apache - Redirecting main domain but not certain subdomain with .htaccess - Stack Overflow

did not succeed

but will look at your suggestion