There's no such thing as a stupid question, but they're the easiest to answer.


Search Search
Search for:
Tech Support Guy > > >

PHP code doesn't work, is it wrong? PHP Redirect code.


tnomal2008's Avatar
tnomal2008 tnomal2008 is offline
Member with 5 posts.
Join Date: Aug 2008
31-May-2012, 09:49 AM #1
PHP code doesn't work, is it wrong? PHP Redirect code.
Can anyone assist? I'm not a programmer so please forgive me in advance.

Iíve tested the code below but itís not redirecting (no errors on the page) As an FYI, I tested only using two incoming links, I added the third elseif here for better clarification.



Need to capture campaign ID from print ads and/or direct links. An easy fix would be a tracking pixel on the page but our current analytics program does not provide it (canít purchase another program, our company is too invested in the current).


To just add another elseif expression for new print ads and/or redirects, i.e. until our analytics company develops a solution (simple as opposed to creating a sub domain w/ a redirect for each new incoming link)

Important Notes:

The code should be case sensitive because the incoming link may sometimes come from same domain but with a different campaign ID (see example below)

I did manage to capture the campaign ID using to two domain autoforwards but that will only work for one incoming link.



Print Ad URL #1 >>>domain autoforward>>> >>>php redirect>>> PrintAD1

Print Ad URL #2 >>>domain autoforward>>> PrintAD2 >>>php redirect>>> www. PrintAD2

Print Ad URL #3 >>>domain autoforward>>> PrintAD3 >>>php redirect>>> www. PrintAD3


<?php $referrer = $_SERVER['HTTP_REFERER'];
if (stripos($referrer, ' ') !== false)
{ header("location: PrintAD1"); }

elseif (stripos($referrer, ' PrintAD2 ') !== false)
{ header("location: www. PrintAD2"); }

elseif (stripos($referrer, ' PrintAD3 ') !== false)
{ header("location: www. PrintAD3"); }

As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


Search Tech Support Guy

Find the solution to your
computer problem!

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Forum Jump

You Are Using: Server ID
Trusted Website Back to the Top ↑