Jump to content

PHP Redirection

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
Is it better to add an HTML redirection or to do PHP redirection?
How is redirection done using PHP?

#2
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
in php its simple:
<?php
header("Location: http://google.com");
?>
simply put that on the top of your php page and change "http://google.com" to whatever.

#3
the-chad

the-chad

    Newbie

  • Members
  • PipPip
  • 23 posts
your browser will not cache the page if you do that tho.

use this if you want the browser to cache the page:

<?php
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: http://google.com");
?>


#4
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
I'd say PHP.

Isn't it better if the browser doesn't cache?

#5
the-chad

the-chad

    Newbie

  • Members
  • PipPip
  • 23 posts
depends on what your doing. If its a perm redirect it would be good if the browser cached the page.

But if you change it alot then no it will be a bad idea.

#6
Guest_Kaabi_*

Guest_Kaabi_*
  • Guests
A PHP redirect looks a lot simpler than an HTML redirect. I thought it was going to be all complicated, but it wasn't.