I need a short script that will recognize if the traffic for a site is a type-in traffic (i.e if the user accessed the page by typing the URL directly in the browser), or the traffic is referred from another website. So this is what it needs to do If (traffic == typein) Redirect to www.website1.com Else Redirect to www.website2.com
<? if (isset($_SERVER['HTTP_REFERER'])) header("Location: http://www.website1.com",true,301); else header("Location: http://www.website2.com",true,301); ?> PHP:
Actually I forgot to mention that I wanted to do a frame redirect, I used my lousy PHP skills and html coding to come up with this code, I have some syntax error in the PHP coding probably so when the file is executed is shows blank. <? if (isset($_SERVER['HTTP_REFERER'])) { echo ' <frame src="www.website1.com" name=mainwindow frameborder=no framespacing=0 marginheight=0 marginwidth=0> </frame></frameset> <noframes> '; header("www.website1.com",true,301); echo '</noframes>'; } else { echo ' <frame src="www.website2.com" name=mainwindow frameborder=no framespacing=0 marginheight=0 marginwidth=0> </frame></frameset> <noframes> '; header("www.website2.com",true,301); echo '</noframes>'; } ?> PHP: Could you tell me what's wrong with the code
Please try <?php if (isset($_SERVER['HTTP_REFERER'])) { echo '<iframe scrolling="no" frameborder="0" src="http://www.website1.com"></iframe>'; } else { echo '<iframe scrolling="no" frameborder="0" src="http://www.website2.com"></iframe>'; } ?> Code (markup):
Thanks a lot, this code works, meaning it executes, however, the iframe is messed up and the website isn't displayed properly, I guess the webpage should be framed in different way, any ideas?
You can name the iframe, set width and heights and also use id and make use of css. If you can post up a screenshot or a URL, i can check and help you.