Simple 301 or 302 redirects with Apache or PHP

It behooves you to make sure you’ve only got one URL that serves a given piece of content–so says google. But what if you’ve got a bunch of domains that go to your page?

For this blog, for example,, and all go to the same place. That was done with an apache redirect in /etc/apache2/sites-enabled/matthew:

If you want to redirect from one directory to another, PHP makes that pretty simple. This is the contents of my ~/public_html/index.php that directs people into my blog:

You can read more about 301 redirects on wikipedia.

Tagged with: , ,
Posted in Technical HOWTOs