Results 1 to 2 of 2
-
28th Jul 2011, 08:41 PM #1OPBannedWebsite's:
AlibabaHost.comUser redirection based on Location??
Hi,
Can any one tell me the html code for User redirection based on Location i.e if any user visit our website usa it should direct them to .us domain instead of .com domain.
thxanuragblr Reviewed by anuragblr on . User redirection based on Location?? Hi, Can any one tell me the html code for User redirection based on Location i.e if any user visit our website usa it should direct them to .us domain instead of .com domain. thx Rating: 5
-
28th Jul 2011, 11:41 PM #2BannedWebsite's:
worldwidexs.com.auPHP stores information about the referring URL in one of its global variables - $_SERVER. You can easily access that value using the $_SERVER['HTTP_REFERER']. Now what you have to do is to see if any of the 2 domains is in that HTTP_REFERER variable. You can do this using he preg_match function.
This is the code that you can use:
PHP Code:<?
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/site1.com/",$referrer)) {
header('Location: http://www.customercare.com/page-site1.html');
} elseif (preg_match("/site2.com/",$referrer)) {
header('Location: http://www.customercare.com/page-site2.html');
} else {
header('Location: http://www.customercare.com/home-page.html');
};
?>
Instead of using $_SERVER['HTTP_REFERER'] you can use $_SERVER['REMOTE_ADDR'] which carries information about visitors IP address. This way you can redirect users based on their IP address. If you detected that someone is trying to hack your web site you can use that PHP redirect to send him to a ?Thank you page?
PHP Code:<?
$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/192.168.0.1/",$visitor)) {
header('Location: http://www.yoursite.com/thank-you.html');
} else {
header('Location: http://www.yoursite.com/home-page.html');
};
?>
I think that shud help you
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Really conflicted about .name or .com domain for a unique, user based niche.
By keyoian in forum DomainsReplies: 0Last Post: 9th Dec 2013, 06:14 PM -
How To Sop Redirection ?
By r@liablehost in forum Technical Help Desk SupportReplies: 3Last Post: 2nd Jan 2011, 11:36 AM -
Redirection problem
By World Life in forum phpBBReplies: 3Last Post: 15th Dec 2010, 11:17 AM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...