Hi on Facebook the home link has a query string on it like this: facebook.com/?ref=home
when you click the link and navigate to the home page the query is automatically removed. However if I was to manually type in that link the query is NOT removed. Any idea on how they did this?
Easiest way in PHP:
$url = preg_replace('/\?.*/', '', $url);
What Facebook does is probably a JavaScript thing, in that fashion:
if (location.href.match(/\?.*/) && document.referrer) { location.href = location.href.replace(/\?.*/, ''); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With