There are example solutions for the latter in the Forum Library and specifically in the Mod Rewrite Anti-Leech Solution.
What have you tried so far?
If the page and/or directory does NOT exist on your site, than the result of the request is likely a 404. As a result of that 404 your inquiry is possibly a desire to NOT see the failed request, which is a custom raw logs option and has nothing to do with site access. Custom log options are not available when your using shared hosting, however with your own server you may customize the raw log output as you desire.