Here is what I want to achive.
I got help pages in a folder. I handle the 404 errors with a .htaccess Error Document directive. If a user clicks on a help page link the appropriate help link opens in its own window. If it is not there the error php page is called.
I now want to get a notice what page is missing by e.g. an email so I can fix the problem.
As each help file opens in a namned window I like to know if there is a way in php to read the window name? Or any other means to achive this?
I know it is possible in Javascript but a php solution I would prefer.
Error Document Question
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
The window name...no, as PHP is not client side. The url of the page yes.
And take you pick of variables that will tell you what page was called. And then use the mail() function to send an email or sms message for even faster notification 
Code: Select all
print_r($_SERVER);you could do it in htaccess
instead of using the error docs directive, you coula kinda make your own
this will rewrite any file that doesnt exist to error-404.php
because this is an internal rewrite, php's $_SERVER array will now have the proper info in it.
instead of using the error docs directive, you coula kinda make your own
this will rewrite any file that doesnt exist to error-404.php
because this is an internal rewrite, php's $_SERVER array will now have the proper info in it.
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* error-404.php їL]I think this goes about Theory and Design but what do I know?
Anyway here is the solution for anyone who looks this up and needs a solution:
$_SERVER['REDIRECT_URL'] or $_SERVER['REQUEST_URI'] will give you the Pagename that is missing
$_SERVER['REDIRECT_ERROR_NOTES'] will give you the error message
However there is a very important part that need to be paid attention to.
in .htaccess the ErrorDocument directive cannot have the full URL but just the path with a / in front
e.g.
ErrorDocument 404 /404/error.php
if you use
ErrorDocument 404 http://www.justasample.com/404/error.php
those variables above are not correctly set as the correct info is lost in an external redirect.
Anyway here is the solution for anyone who looks this up and needs a solution:
$_SERVER['REDIRECT_URL'] or $_SERVER['REQUEST_URI'] will give you the Pagename that is missing
$_SERVER['REDIRECT_ERROR_NOTES'] will give you the error message
However there is a very important part that need to be paid attention to.
in .htaccess the ErrorDocument directive cannot have the full URL but just the path with a / in front
e.g.
ErrorDocument 404 /404/error.php
if you use
ErrorDocument 404 http://www.justasample.com/404/error.php
those variables above are not correctly set as the correct info is lost in an external redirect.