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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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



Community Member, 219 Posts

8 March 2011 at 5:22am


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:

$url = $_GET["affiliate"];
header("Location: ".$url);

where the front end URL was:

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 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.