Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-22-2001, 09:00 PM   #1
Carpenter
Registered User
 
Join Date: Nov 2001
Location: LA, CA
Posts: 19
redirecting surfers by country?

Hi,

Can anyone tell me the best way to redirect surfers based on their country? The best way I found so far was a php script that used the language of the browser. Would a perl script or htaccess with a domain look-up create too much overhead?

TIA
Carpenter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-22-2001, 09:12 PM   #2
Carpenter
Registered User
 
Join Date: Nov 2001
Location: LA, CA
Posts: 19
here's the script, BTW....

/* LANGUAGE REDIRECTION SCRIPT
Copyright http://www.adulttypeins.com/ 2001.

This script redirects visitors to different pages based on the
default language preference setting in their browser. You will
need to use the 2-letter language codes from the ISO 639 standard when
naming your files.

You can find these ISO 639 codes here:-
http://www.unicode.org/unicode/onlinedat/languages.html

Disclaimer: this script isn't guaranteed to work as documented, or indeed
do anything at all - and it may well blow up in your face. Approach with
caution, and carry a big stick!

You may use this script on your site or redistribute it free, as long as
you leave this header intact, including the copyright and URL.
*/

// The actual program starts below
<?
$langtmp = getenv("HTTP_ACCEPT_LANGUAGE"); // Read the browser default language
$lang2 = substr($langtmp,0,2); // Throw away the junk filler in the code
if(file_exists("$lang2.html")){ // See if a file exists for the language
header("Location: http://www.DOMAIN.com/$lang2.html // yes - send them to that page
}else{
header("Location: http://www.DOMAIN.com/default.html // no - feed them the default
}
?>
// The actual program ends above

/* INSTRUCTIONS

0. Rename this script to "language.php" (or whatever you like!)

1. Upload the script in TEXT mode into the directory in which you
want to run it (your server will need to be set up to use PHP, of
course!)

2. Create a "default.html" file which should contain the page that
you want visitors to see if you don't have content for their
particular language.

3. Create as many "LANGUAGE.html" files as you want to have
languages on your site. LANGUAGE should be the 2-letter ISO 639
code for the language, for instance "en" for English or "fr" for
French (in this example you would create files called "en.html" and
"fr.html"

4. Upload the default.html file and the various language files.

5. Modify the 2 "header" lines to match the full URL of the directory
into which you just uploaded the language files. (Don't forget to change
DOMAIN into YOUR domain!

6. Test the script. If it works, you should be redirected to the page
corresponding to your browser's language (or the default.html page if
you didn't create a page for your language). NOTE: You can check that
both "paths" through the script work by creating a language file
matching your browser setting (the script should send you to the
appropriate LANGUAGE.html page) and then deleting that language file (
the script should send you to default.html)

ADDITIONAL TIPS

A. If you want to feed lost visitors through this script, you can set
up a .htaccess file to redirect 404 error codes through the script. Look
up "htaccess file" in your favorite search engine for more information.

B. Some hosts allow you to create a default page, "index.php", which will
be run automatically when people come to your root URL. If you want ALL
site traffic to be filtered through this script, try making an index.php
file.

C. You can send people to any URL on the web via this script - you don't
have to limit yourself to sending people to other pages on your own site!
So you could, for example, redirect visitors to various affiliate program
URLs in different languages.

GOOD LUCK AND HAVE FUN WITH THIS! IF YOU FIND A BUG, PLEASE EMAIL
typeins AT bigfoot.com (hey, I want to beat the spambots, ok?)

*/

Carpenter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-22-2001, 09:16 PM   #3
RK
Confirmed User
 
Join Date: Aug 2001
Location: In a Bunker
Posts: 868
Quote:
Originally posted by Carpenter:
Would a perl script or htaccess with a domain look-up create too much overhead?
Yes, the DNS lookups will slow down the loading of your web site too much.
Redirection based on language (either using php, java, perl, C, Apache etc) seems the be the best solution at this point.



------------------
Pay-As-You-Go Hosting FREE Trial!
Below $.90/GB Dedicated Hosting
Limited Time Specials
EnergyHosting - Energizing your business
RK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-22-2001, 09:21 PM   #4
Carpenter
Registered User
 
Join Date: Nov 2001
Location: LA, CA
Posts: 19
Thanks RK,

So, I guess a link to a cgi script in perl looking for the HTTP_ACCEPT_LANGUAGE value would be the best way to redirect some foreign traffic to my favorite top site ;-)
Carpenter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.