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!








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.
Will give you a real 301 Moved Permanently -> good for seo.
If that is what you are going for
Cheers
header(”Location: http://newurl.com“,TRUE,301);
(It stripped out the php tag)
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!
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
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
No problem. I was trying to contribute. Cheers!
Alex