Hi
I'm making a custom 404 page.
I have htaccess redirect 404's to http://www.hiphopmusic.co.uk/index.php?missing=1
However, echoing $REQUEST_URI simply echos "?missing=1", and not the reffering page.
What do i need to do
cheers
James
| SitePoint Sponsor |


Hi
I'm making a custom 404 page.
I have htaccess redirect 404's to http://www.hiphopmusic.co.uk/index.php?missing=1
However, echoing $REQUEST_URI simply echos "?missing=1", and not the reffering page.
What do i need to do
cheers
James
Hmmm, it should do.
Try this instead:
echo $SCRIPT_NAME.'?'.$QUERY_STRING;
OR
echo getenv( 'SCRIPT_NAME' ).'?'.getenv( 'QUERY_STRING' );
The second version is for systems where the ENV variables are not made into globals.
Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting :: From £250/m
Personal Web Hosting :: Budget Web Hosting :: From £50/y
Call 0800 542 9764 today and ask about our Cloud Hosting Platform





Use $HTTP_REFERER will give you the referring page.
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Hmmm, I completly mis-read that one. Guess I should slow down and sleep more, it might help.
Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting :: From £250/m
Personal Web Hosting :: Budget Web Hosting :: From £50/y
Call 0800 542 9764 today and ask about our Cloud Hosting Platform


$HTTP_REFERER does not seem to work either :
http://www.hiphopmusic.co.uk/sdfsdfsdf.html
it should be echoed on index.php here .....link () which ...... between the brackets.
J





It does work!
When I clicked the link, it showed this thread's URL.
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Maybe James wants the bad URL echoed? Here's how we do it at SitePoint:
Code:$thisurl = $SERVER_NAME . $REDIRECT_URL; if ($REDIRECT_QUERY_STRING) { $fullurl = $thisurl . $REDIRECT_QUERY_STRING; } else { $fullurl = $thisurl; }
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference





What does that do, Kevin?
Echo bad URLs? What do you mean by that?
But which variables are provided by user or they're all environment vars?
Thanks
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Basically the above will set $fullurl to the URL that caused the 404 error (rather than the URL that provided the link). We get both and send our administrator an email saying "a link to $fullurl on page $referrerpage caused a 404 error."
All of the variables are environment vars.
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference





Oh nice, where do put it then? In the 404 customized page?
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Yes.
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference


I am still getting the same problem !
try http://www.hiphopmusic.co.uk/sdfsdf.html
Thanks for your help, and it's good to see you back !
J
Using the following code, I too, had problems. Am I missing anything?
[code]<?php
$thisurl = $SERVER_NAME . $REDIRECT_URL;
if ($REDIRECT_QUERY_STRING)
{
$fullurl = $thisurl . $REDIRECT_QUERY_STRING;
}
else
{
$fullurl = $thisurl;
}
echo $fullurl . " Unavailable.";
echo $fullurl . " Unavailable.";
?>code]
The error page only returns the the Domain Name.





I am not sure if you could use $REDIRECT_URL directly but the correct form that I know is
getenv("REDIRECT_URL");
And it should return the URL that requested this destination file using redirection (like in .htaccess or config file)
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
If you want your scripts to be portable you should use getenv( 'VAR_NAME' ); as not all installations of PHP expand the environment variables in actual variables.
Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting :: From £250/m
Personal Web Hosting :: Budget Web Hosting :: From £50/y
Call 0800 542 9764 today and ask about our Cloud Hosting Platform
Still, no luck.
test here
http://sprungmind.com/page/exist_not.html
I've tried REQUEST_URI and REDIRECT_URLCode:<?php $redirecturl = getenv("REQUEST_URI"); $servername = getenv("SERVER_NAME"); $thisurl = $servername . $redirecturl; $redirectquerystring = getenv("REDIRECT_QUERY_STRING"); if ($redirectquerystring) { $fullurl = $thisurl . $redirectquerystring; } else { $fullurl = $thisurl; } echo $fullurl . " File Doesn't Exist or is Temporarily Unavailable."; ?>





That page is protected, I got 401 since I don't know the password
And secondly, it's weird when I tried, I got very weird result from getenv("REDIRECT_URL");
It produces some files that I've NEVER seen!
Probably there is some issue with share server (probably those are others' file on the same server!)
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Can you help me understand? I can't duplicate what you speak of.It produces some files that I've NEVER seen!
Probably there is some issue with share server (probably those are others' file on the same server!)
Also, by the way...
username: support
password: thankyou
Your help is graciously appreciated.
Sincerly,
<Edited by Victor on 12-20-2000 at 12:51 PM>





Oh, when I used getenv("REDIRECT_URL");
I got:
/grandslam.htm (which is not on my site!)
and a bunch of other weird things (but I don't have it at the moment)
So I guessed it could be some files from other sites on the same server, or it could be anything else, I am not sure!![]()
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Bookmarks