Htacess subfolder rewrite not working

I have a drupal website

www.test.com

I have installed drupal in a subfolder

so when I visit any of the pages

I see them under the subfolder in the url

www.test.com/subfolder/user/1

I want to rewrite it such that I can access the above page as

www.test.com/user/1

here is the htacess code I am using, I got this from the drupal site but its not working

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^(www.)?test.com$
  RewriteCond %{REQUEST_URI} !^/subfolder/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /subfolder/$1
  RewriteCond %{HTTP_HOST} ^(www.)?test.com$
  RewriteRule ^(/)?$ subfolder/index.php [L]

drupal link
https://support.lunarpages.com/knowledge_bases/article/549

mod rewrite is enabled on the server, this is hosted on a shared hosting site

but when I try
www.test.com/user/1

it says page not found, but it works as

www.test.com/subfolder/user/1

any help would be appreciated

At a glance, it looks like it should work. Is the code you showed the entirety of your htaccess?

Thanks for the quick reply, I got it working

there was nothing wrong with the htaccess code, drupal has a feature called Clean Urls, I disabled this feature and so the subfolder rewrite is working now