I count at least two different questions. Easy one first:
Now if i use "ErrorDocument 404 it catches the 404's but doesn't 301 them only 302's them meaning temporary.
Crystal ball says your ErrorDocument directive is in this form
ErrorDocument 404 http://www.example.com/404.html
NEVER give the domain name for an ErrorDocument. This converts the error handling into a redirect. It's 302 rather than 301 because that is the default form of a redirect. But this detail is irrelevant because you don't want ANY form of redirect. A 404 is a 404:
ErrorDocument 404 /404.html
That's all. Leading slash = root. If your error documents are collected elsewhere for convenience, it might be something like
ErrorDocument 404 /errordocs/404.html
Now then...
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . / [L,R=301]
Can I assume the Forums ate a few line breaks so it's really
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
"If user-agent requests any file whatsoever that doesn't exist, redirect to the root."
Smells like your vanilla CMS RewriteRule... except what's the R=301 doing there? The whole point of this type of rewrite is to let the user
think they're at
www.example.com/directory/coolstuff/pagename.html
while really they're getting content from
www.example.com/index.php
... with further wtf? at this point, because the RewriteRule doesn't include any provision for remembering what page the user thought they were going to. With a simple rewrite it wouldn't matter because the original URL is still there. Change it to a redirect and you've effectively killed all your pages. So you've got more problems than the one you posted about.
If your admin area involves a named file in an area that physically exists, there's nothing in the quoted rule that would prevent you from getting there. But the quoted rule only checks for -f files not for -d directories. So if you are trying to get to
example.com/this-way-for-robots/index.php
and all you entered was
example.com/this-way-for-robots/
the rule
will kick in and you'll be redirected. It is probably easiest to code an outright exception in your generic rewrite. Exclude all requests for everything in the admin directory:
RewriteCond %{REQUEST_URI} !/this-way-for-robots/
Just make sure the admin directory is suitably password-protected.
Come to think of it: What happens to ordinary requests after they meet the global redirect? I'd expect an infinite loop.
And then there's the matter of requests for non-page files...