How to show a geoip warning page without using htaccess?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Darrell
    Confirmed User
    • Feb 2003
    • 803

    #1

    How to show a geoip warning page without using htaccess?

    Any tips on how to show a geoip warning page when someone visits a site without using htaccess? I don't want to use htaccess because of server load on high traffic sites.

    Thanks
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55700

    #2
    http://www.maxmind.com/app/php

    http://www.phpandstuff.com/articles/...ookup-with-php
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

    Comment

    • BestXXXPorn
      Confirmed User
      • Jun 2009
      • 2277

      #3
      Indeed, MaxMind is kinda the defacto standard for GeoIP in terms of PHP
      ICQ: 258-202-811 | Email: eric{at}bestxxxporn.com

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47882

        #4
        can do it with php or javascript, dozens of ways actually depending on what exactly you are trying to acomplish...
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • Vick!
          Confirmed User
          • Nov 2005
          • 6882

          #5
          MaxMind of course. That's kickass.
          Affordable Quality Web Hosting

          Comment

          • BestXXXPorn
            Confirmed User
            • Jun 2009
            • 2277

            #6
            PHP Code:
            <?
                $validCountries = array('US', 'CA', '...');
                $countryCode    = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
                
                if(!in_array($countryCode, $validCountries)) {
                    header('Location: http://www.someplace.com/country_not_aloud');
                    exit();
                }
            ?>
            Real quick down and dirty if you need an example (haven't tested but it should work)... List of country codes available here: http://www.maxmind.com/app/iso3166
            ICQ: 258-202-811 | Email: eric{at}bestxxxporn.com

            Comment

            • Prasawet
              Prasawet
              • Nov 2009
              • 65

              #7
              U can use php & mysql IP database.
              ip2nation.com, U can find instructions how to use, I found it 95% accurate, and U are not depend on the third party.

              https://caldasesso.com/

              Comment

              • grumpy
                Too lazy to set a custom title
                • Jan 2002
                • 9870

                #8
                Originally posted by Darrell
                Any tips on how to show a geoip warning page when someone visits a site without using htaccess? I don't want to use htaccess because of server load on high traffic sites.

                Thanks

                .htaccess is the fastesT way and lowest server load, where do you get your info from?
                Don't let greediness blur your vision | You gotta let some shit slide
                icq - 441-456-888

                Comment

                • SmokeyTheBear
                  ►SouthOfHeaven
                  • Jun 2004
                  • 28609

                  #9
                  Originally posted by grumpy
                  .htaccess is the fastesT way and lowest server load, where do you get your info from?
                  not nec. with no htaccess the page will load faster, the warning might be slower than simply using htaccess but i think his point is the page will initially load faster.

                  solution is to use an external file with htaccess geoip so the initial page loads faster.

                  i.e. instead of serving page after checking htaccess , serve page first , call htaccess from an external file such as a javascript
                  Last edited by SmokeyTheBear; 09-30-2010, 11:05 AM.
                  hatisblack at yahoo.com

                  Comment

                  • fris
                    Too lazy to set a custom title
                    • Aug 2002
                    • 55700

                    #10
                    or you can do it based on he language without any lib
                    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                    Comment

                    • BestXXXPorn
                      Confirmed User
                      • Jun 2009
                      • 2277

                      #11
                      .htaccess should not ever be used unless you don't have control over your own web server...

                      In fact I'd highly recommend you don't run Apache... it's bloated and ass slow compared to newer web servers... You can't really beat nginx serving PHP via Fast-CGI. I've taken 12 box Apache deployments down to 4 nginx boxes and still had less load than all 12 boxes running Apache...
                      ICQ: 258-202-811 | Email: eric{at}bestxxxporn.com

                      Comment

                      • HomerSimpson
                        Too lazy to set a custom title
                        • Sep 2005
                        • 13826

                        #12
                        php + session
                        php or js + cookie
                        Make a bank with Chaturbate - the best selling webcam program
                        Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

                        PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:

                        Comment

                        • Darrell
                          Confirmed User
                          • Feb 2003
                          • 803

                          #13
                          Originally posted by fris
                          or you can do it based on he language without any lib
                          Thanks for all the replies. Based on language is a good idea.

                          My sites are in English and I only want to pop a warning page for one country and based on the browser language would be fine. Also I don't want to mess up my SE rankings. Is there a really simple way to accomplish this?

                          Comment

                          • Darrell
                            Confirmed User
                            • Feb 2003
                            • 803

                            #14
                            With regards to not wanting to mess up SE rankings for showing a warning page for one specific country, would a Javascript redirect be a good idea as I don't think SE bots parse javascripts?

                            Comment

                            • Darrell
                              Confirmed User
                              • Feb 2003
                              • 803

                              #15
                              Bump for me

                              Comment

                              • fris
                                Too lazy to set a custom title
                                • Aug 2002
                                • 55700

                                #16
                                Originally posted by Darrell
                                Thanks for all the replies. Based on language is a good idea.

                                My sites are in English and I only want to pop a warning page for one country and based on the browser language would be fine. Also I don't want to mess up my SE rankings. Is there a really simple way to accomplish this?
                                Code:
                                <?php 
                                $lang = ($_SERVER['HTTP_ACCEPT_LANGUAGE']); 
                                
                                if(preg_match("zh", $lang)) { 
                                    header("location: http://www.domain.com/china.html"); 
                                } else { 
                                    header("location: http://domain.com/"); 
                                } 
                                ?>
                                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                                Comment

                                Working...