July 10, 2008

I’m back from a nice fourth of July weekend and am refreshed and ready to hit the road running! The social address book is very nearly finished, which is extremely exciting. It seems as if new features are added all the time! Luckily it was designed with a large scope in mind, so scalability shouldn’t be too big of an issue.

Anyhow, would you like to know how to redirect a page in PHP without worrying about META Refresh and all that fun jazz?

Here you go:

<?php
# very basic redirect
include newpage.php;  ?>

Simple, eh? Just include the page. So now, when you have multiple domains, just make an include!

  1. Hey… is that really a redirect?

    I figured you were going to mention the header() tag… like, header(”Location: http://newurl.com“). That’s an actual redirect. ;)

    fdask on July 15th, 2008 at 5:20 am
  2. Will give you a real 301 Moved Permanently -> good for seo.
    If that is what you are going for

    Cheers

    Alex Barger on July 16th, 2008 at 4:17 am
  3. header(”Location: http://newurl.com“,TRUE,301);

    (It stripped out the php tag)

    Alex Barger on July 16th, 2008 at 4:18 am
  4. Alex, this would not give a 301 moved permenantly error because PHP utilizes “includes” in its very basic nature. This would imply that an include in PHP would give a 301 error to googlebots, which is false.

    While header() is ideal and proper, an easy/temporary alternative would be to use an include like this. The post was more informatory to help those having troubles with the header tag.

    Thanks for posting!

    Nathan Blazek on July 16th, 2008 at 10:35 pm
  5. Ok. So I put this in a script called sample.php on my host.

    <?php
    header(”Location: http://blazekwebdesign.com/blog/2008/07/redirect-a-page-in-php/“,TRUE,301);
    ?>

    So then when you go to this url
    http://www.cruzinthegalaxie.com/sample.php
    It redirects you over to this permalink.

    If that was not the point of the post, and you want to do in the include, then I get your point.

    Cheers

    Alex Barger on July 20th, 2008 at 10:21 pm
  6. Absolutley! Of course, I would suggest using the header tag first before using anything else, but some users have difficulty interpreting the tag, so I posted this as an alternative, not perfect, but it would wok for those users.

    Thanks for the engaged discussion

    Nathan Blazek on July 21st, 2008 at 6:36 pm
  7. No problem. I was trying to contribute. Cheers!

    Alex

    Alex Barger on July 22nd, 2008 at 9:46 pm
Would you like to login?