'After extension is removed, if file doesn't exist, send to a particular page

My question is somewhat similar to this one but not exactly and I can't understand it enough to adapt it to my needs.

I have this htaccess rule to remove file extensions which works well

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

So /somepage refers to /somepage.php. I now need a sort of fallback to it incase somepage.php doesn't exist.

In which case /somepage would rewrite to /catchall.php?link=somepage which can handle the requests. How can I do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source