Page 4 of 8 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 78

Thread: How can i redirect bad traffic?

  1. #31
    Mike-XS's Avatar
    Mike-XS is offline XeroAgent
    Join Date
    Sep 2009
    Location
    OZ
    Posts
    209
    Thanks
    30
    Thanked 109 Times in 71 Posts
    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
    Ok lets go back to the start. Are you trying to use this code with a proxy script or some other kind of site ?

    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.

    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?
    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.

    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.

    GeoIPEnable On
    GeoIPDBFile geoip.dat
    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.

    My hosts don't have that file, so where do I get it and more importanly, where do I put it please?
    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.

    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.
    Last edited by Mike-XS; 20 April, 2011 at 07:06 AM.

  2. #32
    _Chris_ is offline Newbie Net Builder
    Join Date
    Apr 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for your time and patience Mike - it's appreciated. Am getting onto the hosts now to ask them if they have the Apache GEOIP module and will let you know.

  3. #33
    _Chris_ is offline Newbie Net Builder
    Join Date
    Apr 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Mike, here's the response from the hosts

    --------
    I've checked on the server, the module mod_geoip.c is not installed on the server where your Linux Unlimited Reseller account is hosted.

    Please let us know if we can help you further in this regards.
    ----------------

    What's the next step please?

  4. #34
    Mike-XS's Avatar
    Mike-XS is offline XeroAgent
    Join Date
    Sep 2009
    Location
    OZ
    Posts
    209
    Thanks
    30
    Thanked 109 Times in 71 Posts
    I guess you have at least these four options to choose from.

    1: Ask your host to install the Apache GEOIP Mod.
    2: Try setting the location of the geoip.dat file in your .htaccess file and test if that works.
    3: Use the PHP code instead of the .htaccess file.
    4: Move to Vectro where everything is already setup properly for a proxy site.

  5. #35
    UncleP's Avatar
    UncleP is online now The perfect face for radio
    Join Date
    Nov 2009
    Location
    Blighty
    Posts
    214
    Thanks
    20
    Thanked 90 Times in 60 Posts
    I use the php modded geoIP version myself, and it works well for me. I've put the code (posted elsewhere on here) at the top of the index.php and the browse.php files, that way the proxy is off limits to any blocked countries, even if they get around the hotlinking ban (which is not perfect, enabled or not) but can still see the terms/privacy/cookies pages, which don't use any bandwidth. I've got the GeoIP.dat & geoip.inc files in the home directory of the vps I use, then I only have to update the one file for all proxies, but it works just as well in the root (public_html) or /includes/ folder for normal hosting, as long as the path info is correct it'll work OK. Plus it works on any hosting, I use the same install files for all new proxies and I know I'm blocking the spammers/phishers/bandwidth thieves already

    There is a javascript way too but it's not so reliable, is easier to get around and could have speed penalties. It's OK for testing though and is the only thing that works on freeproxyhosting. You'll have to PM me for that one.
    If I can't be a good example, I'll just have to be a terrible warning...

    Check website whois and PR on TheSiteCheck.com

  6. #36
    _Chris_ is offline Newbie Net Builder
    Join Date
    Apr 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just had this bacvk from the hosts - "We have installed the "Geo::IPfree" perl module on the server"

    Does this change anything ?

  7. #37
    UncleP's Avatar
    UncleP is online now The perfect face for radio
    Join Date
    Nov 2009
    Location
    Blighty
    Posts
    214
    Thanks
    20
    Thanked 90 Times in 60 Posts
    Quote Originally Posted by _Chris_ View Post
    Just had this bacvk from the hosts - "We have installed the "Geo::IPfree" perl module on the server"

    Does this change anything ?
    It means that you can now use .htaccess country blocking I think, just add a few lines to your .htaccess file and all the 'bad' countries will get a "your name's not down, you're not coming in" message, or a redirect, the choice is yours. I hope you've thanked your host, they would welcome your appreciation I'm sure.

    There are a few different codes for blocking countries, depending on what you want it to do, some codes have already been posted here but there's a useful reference on Vectro's KnowledgeBase here too.

    How you do it is not inportant, but you should see your ad revenue increase and your bandwidth usage decrease significantly, it's well worth doing. Trial and error is how to find out what works best for you, just be ready to change it back if it doesn't work (copy/rename all the original files you change - just in case) and check it after you make any changes, you wouldn't want to break it.

    Good luck
    If I can't be a good example, I'll just have to be a terrible warning...

    Check website whois and PR on TheSiteCheck.com

  8. #38
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    624
    Thanks
    192
    Thanked 100 Times in 79 Posts
    Quote Originally Posted by _Chris_ View Post
    Just had this bacvk from the hosts - "We have installed the "Geo::IPfree" perl module on the server"
    Quote Originally Posted by UncleP View Post
    It means that you can now use .htaccess country blocking
    Actually, I think the Perl module is accessed in a different way than the Apache module. The Apache module is the one that is controlled by .htaccess. The Perl module is for Perl scripts to access the GeoIP database.

    More info: MaxMind - GeoIP Perl API
    The Perl module can also be used in conjunction with AWStats: http://forum.maxmind.com/viewtopic.php?t=27

  9. #39
    UncleP's Avatar
    UncleP is online now The perfect face for radio
    Join Date
    Nov 2009
    Location
    Blighty
    Posts
    214
    Thanks
    20
    Thanked 90 Times in 60 Posts
    Quote Originally Posted by vectro View Post
    Actually, I think the Perl module is accessed in a different way than the Apache module...
    Oops, my mistake , that just goes to show how much I (don't) know about these things. Is the perl a cgi-bin thing then? Maybe not so useful.

    @_Chris_ - I'll PM you the javascript one, you just copy 'n paste that into your webpage, I like simple myself and that's as easy as it gets. Let me know if it works for you.
    If I can't be a good example, I'll just have to be a terrible warning...

    Check website whois and PR on TheSiteCheck.com

  10. #40
    _Chris_ is offline Newbie Net Builder
    Join Date
    Apr 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the pm Mike - it's appreciated.

    ---------- Post added at 23:11 PM ---------- Previous post was at 23:10 PM ----------

    Am I able to use the .htaccess file for this at all please ?

Page 4 of 8 FirstFirst ... 23456 ... LastLast

Similar Threads

  1. Non www to www redirect
    By tetrapak in forum Managing
    Replies: 8
    Last Post: 31 May, 2010, 18:19 PM
  2. [WTS] Traffic | Traffic | Traffic | Dont forget to check inside
    By squintoo in forum Services
    Replies: 2
    Last Post: 16 October, 2009, 15:12 PM
  3. 301 redirect all to all
    By Hellas in forum Managing
    Replies: 0
    Last Post: 27 August, 2009, 12:25 PM
  4. How to redirect traffic with CSF?
    By ProxySites.ca in forum Web Hosting
    Replies: 1
    Last Post: 5 August, 2009, 23:47 PM
  5. Non-www. to www. 301 redirect
    By Dr. Stavros in forum Managing
    Replies: 8
    Last Post: 29 July, 2009, 18:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •