websitings Posted May 8, 2006 Share Posted May 8, 2006 I am seeking guidance for the following challenge.If someone visits my website using a non existant page url or may just have typed incorrectly in the browser location.For example they may have typed:[a href=\"http://www.mydomain.com/a/nonexistant\" target=\"_blank\"]http://www.mydomain.com/a/nonexistant[/a]I would like the browser to maintain what they have typed in the address box but I would like to display a page which can handle a php script to display a message based on what they entered for the url.I would have no problem writing the script to display the message but I am struggling on working out how to maintain the url which is important to me. I can work out how to use htaccess for a 404 redirect but that's not what I wantI assume it would be using some 404 handler but can't work it out myself. Any help greatly appreciated. Quote Link to comment Share on other sites More sharing options...
ober Posted May 8, 2006 Share Posted May 8, 2006 You will need to have access to the 404 handler provided by your server. Normally this is like 404.shtml or something similar. You will have to overwrite this file with whatever comments your users need to see. You should be able to catch the URL and then redirect or whatever you need to do. Quote Link to comment Share on other sites More sharing options...
alpine Posted May 8, 2006 Share Posted May 8, 2006 you can actually do this with htaccess aswell (least on my host's server setup),i have something similar to this in my .htaccess (note: NOT full url):ErrorDocument 404 /index.php?page=404_errorErrorDocument 403 /index.php?page=403_errorand in index i use switch to load the 403/404 pages i made. When i hit for example www.mydomain.no/jhgfaqgfa - the htaccess loads the index switch while the url still is the same as when mistyped - no change.by using $_SERVER['REQUEST_URI'] in your 403/404 document, you can split and use whatever is in the adress bar. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.