Automatic frame redirect (cloaking) with apache and PHP
daniel posted this on Aug 11th 2008 under Howto, Scripting
Sometimes a customer wants redirection using a frame. What you as an ISP don't want to do is make webspace and a index.html file for each customer handling this. You want this automated somehow.
This is how i did it.
First set up redirection with apache.
<VirtualHost *:80> ServerName www.whatever.com ServerAdmin admin@whatever.com DocumentRoot /usr/local/www/apache22/data SetEnv FRAMEREDIRECTURL "http://www.to-where-ever.com/blah/blah" ServerAlias *.whatever.com whatever.com </VirtualHost>
As you can see we set a environment variable containing the URL you want to redirect to.
Next you will need some PHP to generate the frameset. Create this in the documentroot you specified in the virtual host.
<html> <frameset rows="100%"> <frame src="<?php echo $_SERVER['FRAMEREDIRECTURL'] ?>"> </frameset> <noframes> <body>Please follow <a href="<?php echo $_SERVER['FRAMEREDIRECTURL'] ?>">link</a>.</body> </noframes> </html>
This is it. Use this info if you can.
Cheers