Simple mod_rewrite code which verifies that the requested URL isn't a valid file or directory before redirecting:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([0-9]+)/?$ /view.php?id=$1 [L]
Note in the regexp I used, there could be a trailing '/' slash or not, and it will only match numbers.