0

I've created a php 404 page not found and added it to my server settings, this works great.

I want the page to email me the url of the missing page (e.g. /folder/misspeltpagename.php) but all I can get it the url of the 'page not found' page (e.g. /error-docs/not-found.php).

I'm using $_SERVER['SCRIPT_NAME'] to get the url.

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47

2 Answers2

0

I'm guessing that you simply redirect from any invalid page to your 404 page, so you can just use $_SERVER['HTTP_REFERER'] to get what page directed to your 404 page.

0

add this to .htaccess:

ErrorDocument 404 /404.php

and then in 404.php use

$_SERVER['REQUEST_URI']
gio
  • 337
  • 3
  • 8
  • Thank you @gio, this worked however I didn't look at my htaccess file. –  Aug 23 '17 at 18:44