Hi folks.
My server and web programming expertise is with Windows servers and ASP. My PHP is rudimentary at best, and I'm trying to learn as I go along while solving practical problems.
What I need to do is redirect to a specified page on on a different domain when an invalid URL is entered into the browser.
For example if:
http://www.MyActualDomain.com/BadFolder/index.php
does not exist, then the visitor is redirected to:
http://www.MyOtherDomain.com/404handler.php
As I understand it the conventional way to do that is via a redirect in the .htaccess file.
I have done that and it worked fine.
NOW FOR THE PROBLEM:
A script in 404handler.php needs to know the bad URL that caused the 404.
He is a snippet of test code I put together trying to figure out these environment variables:
<?
$host = getenv("REMOTE_HOST");
$referrer = getenv("HTTP_REFERER");
$path = getenv("REQUEST_URI");
echo "REMOTE_HOST = " . $host . "<br />";
echo "HTTP_REFERER = " . $referrer . "<br />";
echo "REQUEST_URI = " . $path . "<br />";
?>
REMOTE_HOST returns my own IP as expected, but the other two strings are empty.
I've also tried $_SERVER['REQUEST_URI'] in place of the getenv method.
Anyone got a solution?
if it matters, here's PHPinfo on the server where 404handler.php resides:
PHP Version 5.0.5
System Windows NT NT24 5.2 build 3790
Build Date Sep 5 2005 15:50:13
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API CGI/FastCGI
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS\php.ini
PHP API 20031224
PHP Extension 20041030
Zend Extension 220040412
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp