• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Custom Error Doc With PHP or ASP

D

daveberk

Guest
Had to figure this out for my needs, thought I would share it with the community.

I wanted to use PHP (or ASP) to process "404 page not found" errors.

I added this JavaScript code to the <head> tag/area of the not_found.html file in the error_docs folder.

<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.<mysite>/error-handler.php?req="+location.href;
// -->
</script>

Then I created my error-handler.php file (in the httpdocs folder) with this code:

@$page = $_GET['req'];

This loads the URL of the error-ed page into the $page variable (ex. http://www.<mysite>/bad-page.html).

The rest is up to you. I am using it to check a database for "subscriber aliases"
(ex. http://www.<mysite>/person1) that I then use to redirect the visitor to a certain page, also stored in the database.

Obviously it won't work for people with JavaScript turned off, but I tend to go with the 99% solutions.

Hope this helps.
 
Back
Top