301 Redirect Pages using PHP

Mon, May 15, 2006

SEO

I have shared this on the SEOPhilippines mailing list and a friend of mine, Noel also from the same group has posted it online on The Search Engine Web Blog and posted it on this page. The Main purpose of this 301 redirect is to forward your website without the “www” to with the “www.” Try visiting http://actiononline.biz and see that it forwards to http://www.actiononline.biz. What difference does it make some may ask, but this is mainly an SEO reason.
Although, every time I use the code, it just gets updated every time. Haha. So here is my latest implementation:

Comparing it with my previous version also on SEOPhilippines.org, the old version will forward a page like http://domain.com/path/page.html to http://www.domain.com/ and not http://www.domain.com/path/page.html. I do suggest into looking into a .htaccess way of doing it with some regex, and probably this method is best if you have some other PHP conditional statements that go with it if you really want to redirect or not, like when you want to the referring URL before you redirect, or the user agent.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

This post was written by:

Benj Arriola - who has written 140 posts on action online.

Started a career as a chemist. Worked in the industry and academe and pursued a master's degree in chemistry. Then one day, here I go, start a computer shop, then web company in 1999, won a few awards and just started a web career working on websites of various companies and making sure the websites work for them.

Contact the author

0 Comments For This Post

1 Trackbacks For This Post

  1. SEM/SEO Tips » Getting out of Google's Supplemental Index Says:

    [...] make it a point I do the right 301 redirects for domain canonicalization issues and I use my own 301 redirect modification using PHP. And that’s basically what I did with my other blogs. Not all my blogs since sometimes I am [...]

Leave a Reply