Htacess subfolder rewrite not working

I have a drupal website

I have installed drupal in a subfolder

so when I visit any of the pages

I see them under the subfolder in the url

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

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.)?$
  RewriteCond %{REQUEST_URI} !^/subfolder/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /subfolder/$1
  RewriteCond %{HTTP_HOST} ^(www.)?$
  RewriteRule ^(/)?$ subfolder/index.php [L]

drupal link

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

but when I try

it says page not found, but it works as

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