Hi,
Is there a script I can use to upload to my server to forward and mask an affiliate page with my domain name?
I used to do it a lot a few years ago with other sites, but now that I'm trying it with another site is not working.
I was told that the affiliate page I'm trying to mask with my domain name is an SSL and that is impossible to forward and mask such site with my domain name. But the affiliate url site opens with both http// and https// Is there a way to accomplish what I'm trying to do?

Dani AI

Generated

Short answer — technically possible, but not by simple client-side tricks. Presenting an affiliate page under a site domain requires either affiliate cooperation (white‑label / custom CNAME or hosted subdomain) or a server‑side proxy that terminates TLS for the site and forwards requests to the affiliate. Framing (the approach mentioned) often appears to work but is frequently blocked by modern sites and browser security controls, and 's warning about the security/abuse surface is well founded.

Two practical approaches and their tradeoffs:

  • Standard redirects or “cloaked” links: simplest and safe for tracking and TOS compliance, but the browser address bar will show the affiliate domain after the redirect.
  • Server reverse proxy (Nginx/Apache) that serves content on the site domain while proxying to the affiliate backend. This can keep the address bar on the site domain, but requires a valid SSL certificate for that domain and careful header/cookie rewriting. Example (illustrative only):
server {
    listen 443 ssl;
    server_name shop.example.com;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        proxy_pass https://affiliate.example.com/;
        proxy_set_header Host affiliate.example.com;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cookie_domain affiliate.example.com shop.example.com;
        sub_filter 'https://affiliate.example.com' 'https://shop.example.com';
        sub_filter_once off;
    }
}

Important caveats: proxying can break affiliate tracking (cookies, JS tokens, referer), run afoul of affiliate TOS, and require handling X‑Frame‑Options / Content‑Security‑Policy, SameSite cookies, CORS, and absolute URLs returned by the affiliate. It also creates support and security responsibilities (serving TLS, logging, PCI/PHI risks if any private data flows through the proxy).

Recommendation for : ask the affiliate first for an approved branding/white‑label option. If that’s not available, use a normal redirect or build a proper landing page that links to the affiliate — those options keep tracking reliable and avoid TOS/security problems.

Recommended Answers

All 3 Replies

perhaps ask support at the affiliate, they may have branding ability
perhaps open a full page iframe with the affililiate site inside

I smooshed up a 'full page iframe' the code is messy but it works as intended

<!DOCTYPE html>
<html lang="en">
<head>
<script>
 function sizer() {
   var viewportheight;
   if(typeof window.innerWidth != 'undefined')
    {viewportheight = window.innerHeight}
   else if(typeof document.documentElement != 'undefined' 
             && typeof document.documentElement.clientWidth != 'undefined' 
             && document.documentElement.clientWidth != 0)
             {viewportheight = document.documentElement.clientHeight}
   else {viewportheight = document.getElementsByTagName('body')[0].clientHeight}
 document.getElementById('extern').style.height=viewportheight-26 + 'px';}
document.onresize = sizer();
</script>
<!--[if IE]><script>window.onresize=sizer();</script><![endif]-->
<title>affiliate</title>
</head>
<body onload='sizer();'>
<div style='height:23px;width:100%;text-align:center;'> 
<a href='<?php echo $_SERVER['HTTP_REFERER']; ?>'>&nbsp;Return to referring page </a>
</div>
<iframe id='extern' frameborder='0' width='100%' height='1px' src='affiliate'>loading page</iframe>
<script>sizer();</script>
</body>
</html>

being able to do that would be (and was) a major security risk. If you can do it, so can a mallicious site...

The affilliate may use a framebreaker script, if they intend to be the topmost page, in which case it will break out of the iframe above
just one example

<script>
if (window != top) { if (top.location.href.indexOf("translate") < 0) {top.location.replace(self.location.href);} }
</script>

so contact the affilliate first to see if they have branding
or to see what the terms of use are

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.