Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

encoding external URL variables


Go to End


1389 Views

Avatar
CHD

Community Member, 219 Posts

8 March 2011 at 5:22am

hi,

I've been trying all day to find a method of using affiliate links on a clients site.
they want the URLs to be handled by a php file so that Google doesn't penalise them for having so many affiliate links.

Initially, i tried this:

<?php
$url = $_GET["affiliate"];
header("Location: ".$url);
exit;
?>

where the front end URL was: http://ultimate-casinos.com/exit.php?affiliate=http://imstore.bet365affiliates.com/Tracker.aspx?AffiliateId=37168&AffiliateCode=365_059963&CID=405&DID=72&TID=1&PID=74&LNG=1

this worked for affiliate links that didnt use ampersands "&"
but some of them do, which were ignored as the URL isnt encoded when added to the CMS.

so then i tried playing around with this:

function nullConverter(url) {
	return url;
}

in leftandmain.js
but obviously that just encoded the WHOLE URL, not just the variable, so then the front end URL was uselss.

now im looking at creating a new entry in HtmlEditorField for something like "Affiliate Link" which would automatically have the http://ultimate-casinos.com/exit.php?affiliate= at the start of the URL, and then have whatever is entered intot he field in the CMS as an ecoded variable.

can anybody help at all with this?
Am i making this WAY too complicated? are there any other solutions?

thanks in advance.