|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
404 Diagnosis
My site log shows a lot of recent hits to my 404 page. Problem is, I can't figure out the erroneous link/URL. I log the referring page, but that doesn't help.
If I enter 'www.mydomain/bad_request.php', I get redirected to 404.php and my log shows a hit to 404.php. The requested URL is not known. Is there a way to log the bad URL request? |
|
#2
|
|||
|
|||
|
What web server are you using? I'm guessing Apache 1.3?
Do you actually get redirected to 404.php, as in does that show in the browser address bar or does it just show the contents of the 404.php page? If it redirects to 404.php properly then you could put some scripting into there to log the referrer, ie: $_SERVER['HTTP_REFERER'] ....which I'd guess should show up and write that to a text file or database. If it doesn't redirect properly, maybe try collecting the value of $_SERVER['REQUEST_URI'] and logging that. If those don't work, try adding phpinfo() to the 404.php, create an error404 and see if this name appears anywhere in the output which should give you a clue as to what you should be looking at collecting. Remember to remove it really quickly however as it probably poses a security risk. On ours if logs the actual page which it couldn't find, but I don't understand it enough to know how it does that... Trev |
|
#3
|
||||
|
||||
|
I remember var dumping the $_SERVER var on one of my error pages once and noticing that there was something called $_SERVER['REDIRECT_ERROR_NOTES'].
I'm not too sure if this works anymore or not, but you could set that up to be emailed to you every time a 404 is encountered |
|
#4
|
|||
|
|||
|
Thanks guys. It was so obvious! The $_SERVER['REQUEST_URI'] variable has the info I needed. I was relying on HTTP_REFERRER before.
|
|
#5
|
||||
|
||||
|
A side note about 'HTTP_REFERRER'.
If this is from Dreamweaver MX then it auto-completes this incorrectly. It adds an extra r in 'referrer'. It should only be 'HTTP_REFERER'. I nearly killed myself one night trying to figure out why this wasn't working for me when I upgraded to Dreamweaver MX. Turns out someone misspelled it in production. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > 404 Diagnosis |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|