Redirect each visitor to my website

Description of your first forum.
Post Reply
charusarma
Posts: 9
Joined: Wed Jan 21, 2015 4:18 pm

Redirect each visitor to my website

Post by charusarma » Thu Mar 05, 2015 4:27 pm

Hello all !
I would like to redirect each visitor to my website coming from a particular country, to other website. Does anyone know how I can do this?

Averyking
Posts: 10
Joined: Wed Jan 21, 2015 2:41 pm

Re: Redirect each visitor to my website

Post by Averyking » Tue Mar 24, 2015 3:52 pm

This solution may be help you

1.Download the latest Geo data and the class file

2.Copy the class file and the GeoIP data file into the same directory where the page is located (most of the time the root directory)

3.Include the class file inside your page and add the following code to request the country using the following code (below the include statements):

$gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE);
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);

4.Define some country codes the "whitelist":

$my_countries = array('us', 'ca', 'gb', 'fr', 'de', 'nl');

5.Next place the following code below the $mycountries array:

if (!in_array(strtolower($country), $my_countries)) {
header('Location: some URL...');
exit;
}

hollyjames879
Posts: 11
Joined: Thu Jan 22, 2015 3:57 pm

Re: Redirect each visitor to my website

Post by hollyjames879 » Thu Apr 09, 2015 10:21 am

You can forward your page to a different page by inserting the following piece of code in your <head> </head> tag:

<meta http-equiv="refresh" content="0; url=http://www.example.com/">

joshuamatthew912
Posts: 10
Joined: Thu Jan 22, 2015 5:13 pm

Re: Redirect each visitor to my website

Post by joshuamatthew912 » Tue Nov 16, 2021 4:54 am

You'll see Redirection mentioned under Tools after it's been set up. Then, under the menu at the top of the page, select Redirects and enter the information for the URL you want to redirect as well as the new URL you want it to refer to. Then select Add Redirect from the drop-down menu.

mahsharghasemiyeh
Posts: 10
Joined: Wed Jan 21, 2015 4:55 pm

Re: Redirect each visitor to my website

Post by mahsharghasemiyeh » Wed Dec 22, 2021 4:13 am

You'll see Redirection mentioned under Tools after it's been set up. Then, under the menu at the top of the page, select Redirects and enter the information for the URL you want to redirect as well as the new URL you want it to refer to. Then select Add Redirect from the drop-downa menu.

Post Reply