• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

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