yhchan Posted November 12, 2008 Share Posted November 12, 2008 Dear all, I need some help on this: Basically what i want to do is, whenever a visitor enters an invalid URL, I would like to redirect to a php file, and then I would like to retrieve the invalid URL and do some string manipulation with it. Let's say visitor type www.mydomain.com/blahblahblah , which is an invalid url. In stead of the standard "404 not found" page, i want all 404 request to be redirected to a php file, and get the whole "www.mydomain.com/blahblahblah" string for some processing. So far I've managed to make the redirection thing works by adding ErrorDocument 404 /somefile.php in my apache configuration file. However, I can't get the invalid URL. I try to get it from getenv("HTTP_REFERER"); but it's empty. Any ideas on how to achieve this? Thanks a lot ! Link to comment https://forums.phpfreaks.com/topic/132395-how-to-retrieve-invalid-url/ Share on other sites More sharing options...
Lumio Posted November 12, 2008 Share Posted November 12, 2008 Create a .htaccess File with the following content: ErrorDocument 404 "/missing.php" And then look into $_SERVER Link to comment https://forums.phpfreaks.com/topic/132395-how-to-retrieve-invalid-url/#findComment-688336 Share on other sites More sharing options...
the182guy Posted November 12, 2008 Share Posted November 12, 2008 yhchan, Check your post on VBF... I have answered it there also. Just use the $_SERVER['REQUEST_URI'] or $_SERVER['REDIRECT_URL']; Link to comment https://forums.phpfreaks.com/topic/132395-how-to-retrieve-invalid-url/#findComment-688343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.