Jump to content


incomming link on 404 page


6 replies to this topic

#1 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 13 March 2009 - 03:48 PM

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

#2 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

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:

// 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... :lol:

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 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 13 March 2009 - 07:17 PM

View PostRalph, 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 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

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...

#5 Dean

    Loves Etomite Forums!

  • Admin
  • 4,745 posts
  • Gender:Male

Posted 13 March 2009 - 10:16 PM

hi, just a quick question... is the referrer string sanitized for XSS?

#6 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

Posted 14 March 2009 - 01:49 AM

View PostDeanC, on Mar 13 2009, 06:16 PM, said:

hi, just a quick question... is the referrer string sanitized for XSS?
No... That requires extra code in the snippet before displaying... I was just seeing if it was possible at this point...

#7 Dean

    Loves Etomite Forums!

  • Admin
  • 4,745 posts
  • Gender:Male

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>
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