1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Custom Error Doc With PHP or ASP

Discussion in 'Plesk for Linux - 8.x and Older' started by daveberk, May 26, 2006.

  1. daveberk

    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">
    // -->

    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.