![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jul 2004
Posts: 7,758
|
geo redirect question
I'm looking for ideas for a geo redirect solution.
I want to be able to redirect traffic from ~200 domains to one domain. I want to do this not by country but by state. One of the server techs at my host has really gone above & beyond in his efforts to help me with this, but so far nothing has really been exactly what I need. As it stands, he's created a solution where a geo ip database and state blacklist reside on a shared folder on the server so that all domains can access it. This is important because I don't want to edit 200 separate domains every time I need to add or drop a state. His setup has every .php request being prepended with a call to go to a .php file that checks the user IP against the geo database and then either allows it to pass or redirects the request to a SFW domain. This is perfect for the .php files; but it's not the .php files that I need redirected, it's the image files .jpg .png etc. My only idea that would work with this setup is to .htaccess DENY FROM ALL the image folders then use the .php page to dynamically alter the .htaccess file and ALLOW FROM user ip's that did not trigger the redirect. This is far from ideal because it's going to cause the .htaccess files to grow quite large, requiring periodic purging of the ALLOW FROM ip's, which requires keeping track of when they were added so I can purge them every hour or whatever. it's also going to require me to edit ~200 .php files and even more image folders across all of my domains to set up this elaborate scheme. There must be a simpler way ![]() PS - one more wrench in the works; my servers reside in a state that will be redirected, so they need to be able to exempt their own IP's so that they may communicate with one another.
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jan 2003
Posts: 962
|
I would just redirect by country and then let surfer pick state. Those ip databases are not accurate for states on mobile devices. I used to show visitors location, now it's not worth it with the bots. Anyway it's simple with JavaScript and any premium IP location database API.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Apr 2025
Posts: 39
|
This can be achieved with .htaccess, Apache and Cloudflare
SetEnvIf CF-IPCountry (.+) GEO_COUNTRY=$1 RequestHeader set X-Debug-Country "%{GEO_COUNTRY}e" You will need mod_setenvif and mod_headers installed for Apache |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
making it rain
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,034
|
There's no reason you can't also use modrewrite to intercept image calls and run them through php as well.
It sounds like you're over complicating something basic. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Jul 2004
Posts: 7,758
|
thanks for the replies!
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Web & App Development
Industry Role:
Join Date: Oct 2023
Location: United States
Posts: 124
|
If you're using MaxMind and Apache:
https://github.com/maxmind/mod_maxminddb If you're using MaxMind and Nginx: https://github.com/leev/ngx_http_geoip2_module
__________________
Cerulean Software Specializes in Website and App Development. Email me today! Keep Your Business and Members Area Secure with LoginBlue Password and Content Protection |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,313
|
also use the php c extension for max mind,its a lot faster.
quite a diff using maxmind for 100,000 lookups 45 seconds, with the maxmind c extension less than half a second
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Jul 2004
Posts: 7,758
|
thanks for the advice all, it is appreciated!
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |