On Sat, Mar 22, 2008 at 5:36 PM, photo312 <[EMAIL PROTECTED]> wrote:
>
>
>  Thank you all for your replies. May I ask why someone said that hacking this
>  in PHP is not a good idea?

Hey,

should have elaborated.

I called this a hack because I see a webapp in a layered model. Which
means that (if we forget about tcp/ip for a second and simplify this
all the way) the first layer is your httpd (e.g. Apache) and then PHP.
Redirecting can be done in PHP, no questions asked, but (IMHO) it is
by no means the best fit. It's more the poor man's approach to
redirecting.

As others mentioned before you should either redirect completely in
the <VirtualHost /> or look into mod_rewrite if you need to be more
selective about which urls need SSL and which don't. It's (IMHO) more
flexible and generally a redirect has less to do with PHP since it's
pure http. mod_rewrite allows you to match URLs (e.g. /user/login) and
check the protocol/port (RewriteCond %{SERVER_PORT}!443$) and redirect
based on that. Since most people have mod_rewrite nowadays I see no
reason to do this in PHP.

But that's just my opinion. Of course you could also redirect with
JavaScript. ;-)

Cheers,
Till

Reply via email to