You can force 404 using the method
show_404();
This will show 404 whenever you want. In your case, just catch your mistake and use this function.
Or you can install your own error handler, register it and display 404, I thought that I do not recommend doing this.
source share