Page 1 of 1

Showing different embed template based on referrer

Posted: Thu Aug 09, 2018 11:52 am
by Psytonic
Ok, let's say traderA.com visits the index page of my tube site, how can I show them a different video/embed page template once they click through the site to those pages? Normally once they hit the index and then to the category > video pages the referrer is now own domain, not the original ref. I'm pretty certain this could be done somehow with htaccess.

I've used referrer checking before to show a different template on a page like this:

Code: Select all

RewriteCond %{HTTP_REFERER} traderA.com [OR]
RewriteCond %{HTTP_REFERER} traderB.com [OR]
RewriteCond %{HTTP_REFERER} traderC.com
RewriteRule ^index.php$ new.php [L]
Would just love to be able to do that with the video pages too. I thought maybe something like this could work:

Code: Select all

RewriteCond %{HTTP_REFERER} traderA.com
RewriteCond %{QUERY_STRING} ^(.+)$ 
RewriteRule ^video/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/index.html$ /scj/tube/?slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/$ /scj/tube/?slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/([0-9]{1,2}).html$ /scj/tube/?slug=$1&item_id=$2&force_template=embed2 [L]
Any ideas?

Re: Showing different embed template based on referrer

Posted: Thu Aug 09, 2018 12:46 pm
by admin
Are you sure you need a separate template or you need just a couple of modifications in an existing one?

Re: Showing different embed template based on referrer

Posted: Thu Aug 09, 2018 10:10 pm
by Psytonic
I thought a separate template would be the only way because some of the html/javascript code will be different on this template to the standard one. Overall not much code will be different. The same related videos will be shown and the same video embeds/descriptions etc etc.

Re: Showing different embed template based on referrer

Posted: Fri Aug 10, 2018 12:36 am
by Psytonic
It's really just a code block or two that I want shown to specific referrers.

Re: Showing different embed template based on referrer

Posted: Sun Aug 12, 2018 10:30 am
by admin
You can add

if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com') {

your code

}

Re: Showing different embed template based on referrer

Posted: Mon Aug 13, 2018 4:41 am
by Psytonic
Thankyou, and if I want to use multiple traders? Something like:
if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com|trader2.com|trader3.com') {
??

Re: Showing different embed template based on referrer

Posted: Mon Aug 13, 2018 5:21 am
by admin
if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com' or $GLOBALS['SCJ_VISITOR']['trader'] == 'trader2.com')

dedicate 20 minutes of your time to read about basic PHP syntax , it'll save you a lot of time