For information I solved this a different way and this is in case anyone is interested.
What I wanted to do was to have files accessible only to members (of my sports club). An easy way to protect files is with HTTP basic authentication the problem then is you need to authenticate yourself with that as well as your site logon - very boring.
The solution I thought is to "fix" authentication on the client somehow - but I did not know how to do this and the solution suggested using $_SERVER variables did not work.
The solution I found is to recognise something I did not realise, namely that Apache protected files can still be read using fread and even included using include in php scripts. Problem solved - instead of directing the browser to the file, I just read it and echo it out.
Very handy to know I think.
Dave