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 05-14-2025, 03:57 PM   #1
AmateurFlix
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 This seems like something better suited to a DNS level redirect rather than screwing around with each and every index.php and image folder on my system.

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.
__________________
AmateurFlix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-14-2025, 07:47 PM   #2
money biz
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.
money biz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-14-2025, 08:01 PM   #3
lemonlinx
Confirmed User
 
lemonlinx's Avatar
 
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
lemonlinx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-14-2025, 09:45 PM   #4
fuzebox
making it rain
 
fuzebox's Avatar
 
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.
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-15-2025, 08:35 AM   #5
AmateurFlix
Confirmed User
 
Industry Role:
Join Date: Jul 2004
Posts: 7,758
thanks for the replies!
__________________
AmateurFlix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-15-2025, 09:42 AM   #6
cerulean
Web & App Development
 
cerulean's Avatar
 
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
cerulean is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-15-2025, 04:16 PM   #7
fris
Too lazy to set a custom title
 
fris's Avatar
 
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
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-16-2025, 08:35 AM   #8
AmateurFlix
Confirmed User
 
Industry Role:
Join Date: Jul 2004
Posts: 7,758
thanks for the advice all, it is appreciated!
__________________
AmateurFlix 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

Tags
.php, redirect, files, geo, image, domains, ips, .htaccess, reside, redirected, folder, folders, database, request, setup, file, edit, user, server, ~200, domain, solution, require, hour, question



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.