A quick domain HTTP permanent redirect script for Apache/PHP

I mentioned earlier that to get my old domains, tamasrepus.hotnudiegirls.com and tamasrepus.rhombic.net delisted from search engines, I was going to write a redirection script that would send an HTTP status 301 (permanent redirect) to anything that tries to access those domains. It would send them to this current domain (samat.org).

And I did. So, behold the script (save as index.php):

Simple enough. More is needed, though: the web server needs to be told to use this script for all URLs. You can do this easily with Apache and the ErrorDocument directive:

<VirtualHost 72.36.165.250:80>
  ServerName tamasrepus.hotnudiegirls.com
  DocumentRoot "/path/to/directory/containing/script"
  ErrorDocument 404 /index.php
</VirtualHost>