Hi All!
For debugging my .htaccess file and the final step in moving my website, I'd like to make the 404 page display the incomming link.
How do I do this?
Now the page is just it's default and it displays only the warning and a link to the search page. Is there a way to get the complete link that generated the error and have it displayed on the error page?
Thanks a lott!
Jeroen
incomming link on 404 page
Started by Jeroen, Mar 13 2009 03:48 PM
6 replies to this topic
#1
Posted 13 March 2009 - 03:48 PM
#2
Posted 13 March 2009 - 05:02 PM
That's a good question, Jeroen... I'll have to do some experimenting to see how the requested page can be sent to the 404 page for display... I'm guessing that using a snippet to grab the referrer will be in order... We shall see...
EDIT:
Ok... I was able to make the 404 page display the original refering page that caused the 404 error... I'd like to think that there is an easier way to do this but I haven't found it yet... Several steps are required and I'll just go over them briefly here...
First, I had to edit the config.inc.php file so it would generate another constant, www_base_path... The modified section of the file now reads:
I then modified the parser, index.php, but I'm not sure what the exact line number it will be because my copy is already modified, but it is around line 630... It now reads...
Once that was done I made a snippet named 404Referer which holds the following line of code...
And finally, I then added the [!404Referer!] snippet call into my Etomite 404 error page...
So, what happens is that when the parser is ready to redirect to the 404 page it compiles and appends the offending URI to the redirect to the 404 page so the snippet can display it... WHEW...!!! Just that simple...
Now, I posted this because this is how I managed to get it to work... Is it ht best way...??? Hard to say... There may be another way to skin this cat but I don't have time at the moment to try...
EDIT:
Ok... I was able to make the 404 page display the original refering page that caused the 404 error... I'd like to think that there is an easier way to do this but I haven't found it yet... Several steps are required and I'll just go over them briefly here...
First, I had to edit the config.inc.php file so it would generate another constant, www_base_path... The modified section of the file now reads:
// build the www path:
$www_base_path = $ETOMITE_PAGE_BASE["www"] = $protocol.$_SERVER["HTTP_HOST"].$ETOMITE_PAGE_BASE["relative"];
define("www_base_path",$www_base_path); // <<<== NEW LINE HERE
I then modified the parser, index.php, but I'm not sure what the exact line number it will be because my copy is already modified, but it is around line 630... It now reads...
// create 404 Page Not Found error url $this->error404page = $this->makeURL($this->config['error_page'],'',"?referer=".www_base_path.ltrim($_SERVER['QUERY_STRING'], "q="));
Once that was done I made a snippet named 404Referer which holds the following line of code...
return $_GET['referer'];
And finally, I then added the [!404Referer!] snippet call into my Etomite 404 error page...
So, what happens is that when the parser is ready to redirect to the 404 page it compiles and appends the offending URI to the redirect to the 404 page so the snippet can display it... WHEW...!!! Just that simple...
Now, I posted this because this is how I managed to get it to work... Is it ht best way...??? Hard to say... There may be another way to skin this cat but I don't have time at the moment to try...
#3
Posted 13 March 2009 - 07:17 PM
Ralph, on Mar 13 2009, 06:02 PM, said:
That's a good question, Jeroen... I'll have to do some experimenting to see how the requested page can be sent to the 404 page for display... I'm guessing that using a snippet to grab the referrer will be in order... We shall see...
Hi Ralph!
Thanx for looking into this. It's just for debugging so a quick-and-dirty sollution works for me :-)
Somewhere in the code etomite decides a page doesn't exists and calls for a 404. Can you easily "hack " a variable pass into it, so a snippet on the 404 page can actually display it?
cheers! Jeroen
#4
Posted 13 March 2009 - 08:06 PM
I was in the middle of my previous edit when I got tied up in a long telephone call so this message is just here so the thread shows unread posts... Read my edited post above, Jeroen...
See http://dahlgren.slyi...m/silly404.html for an example...
See http://dahlgren.slyi...m/silly404.html for an example...
#5
Posted 13 March 2009 - 10:16 PM
hi, just a quick question... is the referrer string sanitized for XSS?
#7
Posted 14 March 2009 - 10:42 AM
Here's another snippet you may find useful (it doesn't show you where they were meant to be going, but shows where they were coming from):
<p>Page you came from: [!referrer!]</p>
Visit: http://www.etomite.o...addressgoeshere
<p>Page you came from: [!referrer!]</p>
if ($_SERVER['HTTP_REFERER'] == "") {$output='Direct Call to URL';} else {$output = $_SERVER['HTTP_REFERER'];}
return $output;
Visit: http://www.etomite.o...addressgoeshere
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











