301使用通配符和.htaccess重定向

I'm new to using 301 redirects so I don't know if this is possible, but I want to take part of the old url and use it in the new url using wildcards.

example.com/folder/file.php to

example.com/newfolder/newfolder/file-keyword/

Where the file name is a wildcard and the name of the file (without the .php) is inserted into the new url example.com/newfolder/newfolder/{insert the file name here}-keyword/

You can use a RewriteRule to accomplish this. For example:

# if its going in your [docRoot]/folder/.htaccess:
RewriteRule ^(.+)\.php http://example.com/newfolder/newfolder/$1-keyword/

# if its going in your [docRoot]/.htaccess:
RewriteRule ^folder/(.+)\.php http://example.com/newfolder/newfolder/$1-keyword/

# if its going in your main config:
RewriteRule ^/folder/(.+)\.php http://example.com/newfolder/newfolder/$1-keyword/

This assumes that your rewrite module is loaded in the main config:
LoadModule rewrite_module modules/mod_rewrite.so

And enabled in the same scope you declare your RewriteRule:
RewriteEngine On