Jump to content

Get which page that wasn't found at HTTP 404 error.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
On my CC sub domain I've (with Virtualmin) set a special page to be shown on a HTTP 404 error like this:
[ATTACH]2236[/ATTACH]
[ATTACH]2237[/ATTACH]

And now my question is: Is it possible (with PHP or anything else) to at my special page (second screenshot) show which page that wasn't found? For example if someone tried to go to the page "http://vswe.codecall.net/ThisPageDoesNotExists" then at the page showed at the second screenshot it will tell the user which page they accessed and then tell them that that page doesn't exists.


Thanks :D

Attached Files



#2
Jacki

Jacki

    Learning Programmer

  • Members
  • PipPipPip
  • 80 posts
<?php

echo "You accessed: ".$_SERVER["HTTP_REFERER"]."<br />This page doesn't exist."; 

?>
Something like this? Bye!
Posted Image

Posted Image

#3
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
I tried it but it didn't work... :(

#4
Jacki

Jacki

    Learning Programmer

  • Members
  • PipPipPip
  • 80 posts
That's strange, what does $_SERVER["HTTP_REFERER"] print out?
PS: How do you tried it?
Posted Image

Posted Image

#5
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Nothing at all...

#6
Jacki

Jacki

    Learning Programmer

  • Members
  • PipPipPip
  • 80 posts
HTTP_REFERER

Quote

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
See this on my space. It work.
Another question: when you do the redirect to ?p=404 you see on the url ?p=404 or still the wrong page?
Posted Image

Posted Image

#7
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
You're seeing the "?page=404" one.

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Just out of curiosity, do
print_r($_SERVER);
At the bottom of your 404 page.

#9
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
I did so and it printed out a lot of stuff, I'll check if I can find what I want somewhere in there.

#10
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I already checked it :)
I was reloading your page waiting for you. The referrer property isn't even being created. How about using javascript?
document.referrer


#11
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Sure, I said that it haven't had to be PHP, I'll try it. :D

#12
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I see that it doesn't work either. I didn't expect it to. I'll look into what it is doing tomorrow if you remind me (ask me thread :) ). It seems more like a server issue not filling in that value.