Ampersands in the HTTP Header

Dear Validator,

I read your page on Ampersands in URLs, and duly arranged all my
URLs to be like this:

<a href="http://www.example.com/index.php?foo=bar&amp;baz=wombat"> link</a>

So far, so good. BUT, if one does the same thing with HTTP headers, eg 
this fragment of PHP:


$redirect_location='http://www.example.com/index.php?foo=bar&amp;baz=wombat';
header("Location: $redirect_location");

then it will fail. It is necessary (tested in both Konqueror and 
Mozilla) to use '&' , NOT '&amp;' in this case. Otherwise, the '&amp;' 
is not evaluated, and the index.php script does not get to know the 
value of baz.

So, I think 3 things arise:

1)Is this a bug in Moz/Konqui, or is it a bug in the various 
documentations (which don't mention this exception)?

2)If I feed the validator with a page containing the above PHP fragment, 
it goes on to validate the page that it is redirected to. It doesn't 
complain about the page that is doing the redirecting, whether I use '&' 
or '&amp;'. Perhaps it should?

3)Why is the behaviour different in an HTTP header than in a link?

Regards

Richard


P.S. I'm not subscribed to this list, so please CC me.





-- 
rn214@hermes.cam.ac.uk  **  http://www.richardneill.org
Richard Neill, Trinity College, Cambridge, CB21TQ, U.K.

Received on Friday, 25 February 2005 03:06:55 UTC