• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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