Question

Let's say I have a referral URL http://www.example.com/r?ref=86745348 and I want to completely hide the r?ref=86745348 part of the URL from my visitors.

I've tried this approach:

<?php
header("Location: http://www.example.com/r?ref=86745348");
exit;
?>

and I've tried url shortners like TinyURL.

All my attempts hide the URL in the hyperlink, but do not hide the URL in the address bar in the user's browser.

No matter what I do, once the user lands on the referral page, they can see the referral link, delete it, and cheat me out of my referral.

So my question is, how can I hide the referral link from the address bar?

Was it helpful?

Solution 2

I agree with @duskwuff. This is wrong... But just for the knowledge scope. This will work. Create a HTML page with the following code and send users to this page.

<iframe src="http://www.example.com" width="100%" height="1024"></iframe>

IDEA: To load a Page A inside Page B using a full page iframe to hide url of Page A

OTHER TIPS

You can't.

If your business plan depends on tricking users into not realizing that you are taking a referral fee, you need to step back and reevaluate what you're doing.

Well the first question has to be - who exactly is monitoring these parameters that are acting as refferals? I assume it's not your server and script that are parsing the $_GET['ref'] parameter no?

Perhaps if the server "counting" the referals actually uses the $_REQUEST parameter as opposed to plain "in-sight" $_GET ones, then you might be able to use $_POST hence "hiding" the parameters from the users.

A quick search on the new and improved search yeilded this helpful answer dealing with redirections with $_POST data.

The logic you are trying to achieve can only be achieved on the receiving end of the hyperlink - you cannot trick a browser into visiting one URL but telling the user they're on another, as that would be a massive security risk.

If the service you are linking to has implemented referral tracking in a sensible way, a cookie will be planted as soon as the user lands on their site, so that removing the query string would have no effect on how the referral is tracked. The target site could even tidy up the URL themselves, redirecting users to a version with no query string, but again, this is something only they can achieve.

If the target site is implemented in such a way that removing the query string is enough to rob you of your referral fee, it is them that is robbing you, not the users.

One way we can do this is by using the Broswer history setting. Following is the code snippet that helped me in my solution

<script>
        $(document).ready(function () {
            //Masking the Url
            var loc = window.location;
            var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
            var absolutepath = loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
            window.history.pushState("Object Or String", "Title", absolutepath);
        });
   </script>

Just copy and paste this code in your .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Very simple

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top