Direct to another folder with .htaccess file Lets say my folder structure looks like this

someproject/v5/.htaccess
someproject/5.0.1/lib.js
someproject/5.0.1/assets/img/png/anotherfolder/helloworld.png
someproject/5.0.2/lib.js
someproject/5.0.2/assets/img/png/anotherfolder/helloworld.png


When user enters url's like (and lets say I am the owner of google.com): 

www.google.com/someproject/v5/lib.js
www.google.com/someproject/v5/assets/img/png/anotherfolder/helloworld.png


I want him to be redirected to version i want using the .htaccess file, example if i want to serve version 5.0.1, then the user will be redirected to this:

www.google.com/someproject/5.0.1/lib.js
www.google.com/someproject/5.0.1/assets/img/png/anotherfolder/helloworld.png


Only one thing may change the version number, this does not work (.htaccess file content):

AddType application/javascript .js
AddType text/css .css

AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)/(.*) "https://google.com/release/theme/5.0.1/$1/$2" [R=302,L]


How can I make it only change v5 with my version number (syntax) ?
The line you are using is telling the engine, redirect everything to the following URI. The reason for this is that you are using the pattern matching wildcard (.*). 

The parenthesis is used for creating groups, the dot is telling the engine that every character is accepted and the star symbol is telling the engine that it can be of unlimited length. By using the forward slash followed by another wildcard group, you are redirecting every URI request to the following URI "https://google.com/release/theme/5.0.1/$1/$2".

Instead of using 

RewriteRule ^(.*)/(.*) "https://google.com/release/theme/5.0.1/$1/$2" [R=302,L]


You should replace it with the following line

RewriteRule ^v5/(.*)$ https://google.com/release/theme/5.0.1/$1 [R=302,L]


Why append the 'v5' before the caret symbol (^)?
The caret symbol matches the start of a string. In our case, the string is the version. 

Source : https://www.searchenginepeople.com/blog/htaccess-redirect-rewrite-rules.html