I am running an forum that checks if the forum URL exists and if not shows an error. How to return 404 error that will then get picked up by the htaccess 404 redirect?
You can’t. Apache will rewrite the request first, and then hand it off to PHP. After that you cant do anything to make Apache back to rewrite again. What you need to do here is send the header yourself using PHP’s header function, and then render a 404 page.
Not… strictly true…you could use the header to push the client to a nonexistant page. I wouldnt do it that way (because then the back button becomes an issue), but it’s doable. OP should however do it the way Scallio has outlined.