Re: General use of rewrite / redirect
| From: | Per Jessen | Date: | Tue, 18 Mar 2008 13:56:37 +0000 |
| Subject: | Re: General use of rewrite / redirect | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271720@lists.php.net to get a copy of this message | ||
Aschwin Wesselius wrote:
> Per Jessen wrote:
>> Yes, that's a very typical setup. When the form is processed, you
>> send a 303 redirect to the "Thank you" page. That way, if the user
>> hits the "back" arrow, he's taken back to the form URL, not the post
>> URL. (which would then warn him about re-submitting etc.)
>>
> Ok, fine. But why do a real redirect when a header with 303 could be
> sufficient? If you model good enough, there would not be a need for
> header(location) redirects. Or am I wrong?
What's the difference between a "real redirect" and a header with a 303?
>> I think there are plenty of perfectly valid reasons for using a
>> redirect, whether dynamically from php or via an apache config.
>> And undoubtedly there equally many poor reason for using redirect
>> and/or rewrite. (they're very different things, by the way).
> I know they're different things. I only want to start a discussion so
> people do understand other techniques instead of just using whatever
> 'works' as a solution to their problem with flow. Redirects do solve
> some issues, but they should be avoided whenever possible.
But redirect and rewrite are not solutions to the same "problem" - a
rewrite is altering the URL internally, a redirect happens externally.
> header(location) mechanisms do come with a very huge disadvantage if
> you don't use them with caution. Requests are reinitialised, libraries
> loaded (again), DB connections setup/checked again, session lookups
> are being done, log write for another request etc. That's quite an
> impact for just not knowing what to do with flow.
I'm having difficulties following you - a plain 303 redirect to a "Thank
you" page shouldn't cause all of that. It's an HTTP reply with the 303
and the new URL, followed by a single URL request from the browser.
/Per Jessen, Zürich