I've got a PHP file situated inside a folder ("www.mysite.com/folder/test.php") which accepts a get argument (str) and allows say print. to be able to result in the Web addresses Search engine optimization friendly I am attempting to rewrite it such as this:

RewriteBase /
RewriteRule ^folder/(.*)$ folder/test\.php?str=$1&%{QUERY_STRING} 

the rewrite rule works fine, the issue is when I have to access the subfolder of this folder. for instance if there's a picture in test.php that's situated at www.mysite.com/folder/images/img.digital, based on the above rule it requires images/img.digital and passes it towards the php file.

just how can prevent that?

Take a look at:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Should solve your condition - this just makes certain that the URL being asked for is neither a real file nor directory around the server.

Whenever you tell it "any character", it thinks that you will do mean ANY CHARACTER.

RewriteRule ^folder/([^/]*)$ folder/test\.php?str=$1&%{QUERY_STRING}