A quick domain HTTP permanent redirect script for Apache/PHP

Tags: •  • 

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):

SERVER['REQUESTURI'];

foreach($headers as $header) { header($header); } ?>

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>

Reply

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
More information about formatting options