When I use this .htaccess code then it’s source URL is returning a 404, Why?

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^name1=([^&]+)&name2=([^&]+)$
RewriteRule ^$ /%1-vs-%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

When I use this .thaccess code then i get this type of link https://example.com/5paisa-vs-abhipra-capital but problem is when i get this url then it’s showing this error “The source URL is returning a 404” so, how to fix this error?