
Originally Posted by
Website Rob
copied and pasted.
This is server configuration code and it is rare that a solution can be a simple copy and paste job and still fit all scenarios. Always be careful when copying code. Make sure it does everything you need it to do.

Originally Posted by
Website Rob
It is easy to pick apart what others have provided as there are usually faults with most code; some of which has been created specifically for a site or purpose.
This code is different. It is suicidally faulty in multiple ways.

Originally Posted by
Website Rob
What is difficult is to provide an alternative. I wonder what alternative coding could be suggested in this case?
Requirements vague, as exactly how deep the folder structure is here, wasn't mentioned. This will work at any folder depth. Not tested, ensure it does exactly what you need it to do:
Code:
# Fails with 404 error, any URL request that includes
# record_company.php/password_forgotten.php
# at any folder depth or root.
RewriteRule ^([^/]+/)*record_company\.php/password_forgotten\.php$ /page-does-not-exist [L]
# Fails with 404 error, any URL request that includes
# images/wp- with 'wp-' being anything that ends with '.php'
# this allows for images named such as 'wp-header.jpg' to work
RewriteRule ^([^/]+/)*images/wp-[^.]+\.php$ /page-does-not-exist [L]
The literal /page-does-not-exist rewrite will cause Apache to serve the 404 ErrorDocument through the standard internal mechanism, and correctly deliver the 404 HTTP status code in the HTTP header. Other methods run the danger of the error page being returned with either 200 or chained 302=>200 HTTP status. Both of those scenarios must be avoided.