.htaccess - 404 redirection - HTTP_REFERER

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

Using the above examples, a script in 404handler.php needs to know the bad URL.

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


-----------------------------------------------------------------------------
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
-----------------------------------------------------------------------------
SoporoseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OscurochuCommented:
try forwarding it to, for example

http://www.MyOtherDomain.com/404handler.php?u=http://www.MyActualDomain.com/BadFolder/index.php

I'm sure there's another way, but that might be the easiest.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hernst42Commented:
Try the following $_SERVER variables for the missed url:
    'REQUEST_URI',
    'QUERY_STRING',
    'REDIRECT_SCRIPT_URI',
    'REDIRECT_URL',
    'HTTP_REFERER'
0
CWS (haripriya)Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
  Delete - no points refunded

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cyberwebservice
Experts Exchange Cleanup Volunteer
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

hernst42Commented:
objection: Split points
0
OscurochuCommented:
I agree
0
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.