Redirect EVERYTHING to your DirectoryIndex (which I have to assume is index.php - I also have to assume that you’ll want to retain the request as “link” in a query string althrough PHP can look at {THE_REQUEST}).
RewriteEngine on
# #1
RewriteCond %{HTTP_HOST} !^www\\.example\\.com$
RewriteRule .? http://www.example.com{REQUEST_URI} [R=301,L]
# this retains the original request while changing to www'd domain (lowercase)
# #2 - This is the query string version
RewriteCond {REQUEST_URI} !index\\.php$
RewriteRule ^(.*)$ index.php?link=$1 [L]
# #2a - This is the NON-query string version
RewriteRule !index\\.php$ index.php [L]
# #2b - Merely use ErrorDocument to redirect 404s to index.php (the handler script)
ErrorDocument 404 /index.php
# Note that the redirection MUST be absolute - this is "internal absolute"
My “insistance” on actually using the DirectoryIndex is (a) hidden and (b) prevents forcing Apache to do additional work (more cycles, more delay) for no useful purpose.