![]() |
javascript
i need to redirect based on referrer
for example #if source www.site.com/folder/0123 >> go link1 or ##if source www.site.com/folder/4567 >> go link 2 or ##if source www.site.com/folder/89xx >> go link3 else , in case the user doesn?t sent his referrer or come from any other source >> just go link4 PS: my current redirect script is .js file not inside html file thanks |
Javascript? It can easily be done in php.
|
the reason i prefer javascript because i will be able to see stats via analytic
php execute faster than anything else :error |
Simple version:
<script type="text/javascript"> if(document.referrer=='http://www.site.com/folder/0123') { window.location='http://whatever_url_1.com '; } else if(document.referrer=='http://www.site.com/folder/4567') { window.location='http://whatever_url_2.com '; } else if(document.referrer=='http://www.site.com/folder/89xx') { window.location='http://whatever_url_3.com '; } else { window.location='http://whatever_url_4.com '; } </script> |
thanks sarettah i will try this code +1 :thumbsup
|
sarettah this worked with me just after doing little change
Code:
if (document.referrer.indexOf('https://gfy.com/') > -1) :thumbsup thanks Quote:
|
Quote:
Your first condition document.referrer.indexOf('https://gfy.com/') > -1 should send anyone from gfy to yahoo. Since the second condition also includes the first condition it will never be hit. So, if you wanted to do that switch condition 1 and 2 around. Make condition 1 be gfy.com/forum and condition 2 be just gfy. That way the ones to the forums will be redirected to msn and then anyone else from gfy will be redirected to yahoo. I had done the exact match conditions because you had included specific pages in your example. As I said, it was a very simple version. Glad it worked for you. . |
Quote:
i will correct that and remove that switch " > -1)" tnx for the heads up , cheers :) |
I suggest you should use ModRewrite (htaccess) with that.
|
Quote:
|
All times are GMT -7. The time now is 12:31 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc