Re: buffering to allow headers in code? [message #170175 is a reply to message #170170] |
Sat, 16 October 2010 15:59 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
MikeB wrote:
> Michael Fesser wrote:
>> At least partly I have to agree. If this is what your instructor told
>> you:
>>
>> header("Location: index.php");
>>
>> then he might be the wrong one for this job. The above violates the HTTP
>> RFC and can be considered a bug. It also violates conventions for good
>> URLs, because you should never link or redirect to index.* files.
>> Instead you use the directory - that's what these index files are for.
>
> Do you mind explaining this? If I understand you, if my site is
>
> http://localhost/recipes/index.php
>
> I should code:
>
> header("location: /") ?
>
> or
>
> header("location: localhost/recipes/") ?
None of the above. You should not need to use the header() function at all:
<http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>
But if you use it, you need to do it as Michael suggested, using
$_SERVER['HTTP_HOST'] in the header field value, for the host name is needed
for an (absolute) URI of the form
http://host/path/
as required by HTTP ─ <http://www.w3.org/Protocols/rfc2616/rfc2616-
sec14.html> ─ and you don't want to hard-code it.
HTH
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
|
|
|