Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » encoding external URL variables

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

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

Page: 1
Go to End
Author Topic: 859 Views
  • CHD
    Community Member
    218 Posts

    encoding external URL variables Link to this post


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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.