Ok lets go back to the start. :) Are you trying to use this code with a proxy script or some other kind of site ?Quote:
Ah, I see, so that would only be for the page being viewed, but I would want this for the whole website, so probably best to stick with the .htaccess file
For the PHP code to cover the whole site, it depends on what kind of site you want to use it on. If your site doesn't route all traffic through an index file or doesn't have one file included in all pages, then you will need to include the GEOIP code at the top of every other php page that you want it to work on.
With Glype, putting the GEOIP code at the top of the index.php file in the root directory will control access to the main proxy form. With hotlinking enabled in Glype, visitors 'should' have to visit the index page first before starting their session to be able to use the proxy. Any visitors will be redirected back to the index page if they try to access proxified pages directly and from there they will be redirected or blocked... This will not stop visitors from opening other pages like the cookies,terms,privacy etc though.
To block/redirect access to all/any Glype page, such as cookies, terms, privacy etc, and direct access to proxified pages (with hotlinking disabled), the best place to put the GEOIP code seems to be at the start of the /includes/init.php file.
With PHProxy, it doesn't have as many files as Glype to worry about and putting the code in the index.php file should cover everything.
That does what you asked for, to redirect everyone but those three countries. Those lines are all you need if you have good proxy hosting (eg: Vectro / xproxyhost ), and the Apache GEOIP module is already installed.Quote:
Code:
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(US|CA|MX)$
RewriteRule ^(.*)$ http://www.google.com$1 [L]
isn't that code in the .htaccess a bit sparse?
If GEO IP mod isn't installed on your server then you will probably need to set where the geoip.dat file is located on your server in the .htaccess file.
I can't test this part because I don't have a server where GEOIP mod is not installed and setting the location of the geoip.dat file in the .htaccess file doesn't work if the mod is already installed, just gives errors.Quote:
GeoIPEnable On
GeoIPDBFile geoip.dat
A .htaccess file is simply a text file, where the file extension is .htaccess and has no filename. You will usually have to create it yourself and upload it your server.Quote:
My hosts don't have that file, so where do I get it and more importanly, where do I put it please?
If you put a .htaccess file in the root directory of your site it will affect every page and every sub directory beneath it. If you put a .htaccess file in a sub directory and nowhere else, it wil only affect that particular directory.
On windows you may have problems creating a file with no filename so to get around that you can upload a text file to your server called htaccess.txt and then rename it to .htaccess, or use filezilla to rename the file while it's still on your harddrive.
You can also use a command prompt in windows to rename a text file to .htaccess. Some windows filemanagers can handle renaming a text file to .htaccess files, like directory opus (or just use filezilla).
Not all webhosts support .htaccess files though, usually only the good ones. And your server must be either Apache or one that supports Apache .htaccess files like litespeed.
If a htaccess.txt file disappears after you rename it on your server to .htaccess then thats a good indication that your host doesnt support it, and you'll need to find a new webhost if you plan on using a .htaccess file. Make sure that your ftp software is set to show hidden files though.
There's tons of info on .htaccess files around, this is one of the best pages - Stupid htaccess Tricks • Perishable Press
Hope that helps.

