# Build and start the container
docker-compose up --build -d
# Run automated tests
./test-scripts/test-countries.sh
# Open testing interface in browser
open http://localhost:8080/geoip-mock.php
curl http://localhost:8080/?country=DE
curl http://localhost:8080/?country=UK
curl http://localhost:8080/?country=US
curl -H "X-Test-Country: DE" http://localhost:8080/
curl -H "X-Test-Country: UK" http://localhost:8080/
curl -H "X-Test-Country: US" http://localhost:8080/
Visit http://localhost:8080/geoip-mock.php for interactive testing with country buttons.
# Test Google Bot with different countries
curl -H "X-Test-Country: DE" -A "Googlebot/2.1" http://localhost:8080/
curl -H "X-Test-Country: UK" -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" http://localhost:8080/
# Test Google Bot without country (should not redirect)
curl -A "Googlebot/2.1" http://localhost:8080/
| Code | Country | Expected Redirect | Flag |
|---|---|---|---|
US |
United States | No redirect | ๐บ๐ธ |
GB |
United Kingdom | /uk/ |
๐ฌ๐ง |
DE |
Germany | /de/ |
๐ฉ๐ช |
FR |
France | /fr/ |
๐ซ๐ท |
LU |
Luxembourg | /fr/ |
๐ฑ๐บ |
AU |
Australia | /au/ |
๐ฆ๐บ |
AT |
Austria | /at/ |
๐ฆ๐น |
CA |
Canada | /ca/ |
๐จ๐ฆ |
IE |
Ireland | /ie/ |
๐ฎ๐ช |
IT |
Italy | /it/ |
๐ฎ๐น |
CH |
Switzerland | /ch/ |
๐จ๐ญ |
LI |
Liechtenstein | /ch/ |
๐ฑ๐ฎ |
ES |
Spain | /es/ |
๐ช๐ธ |
| Other | Any other | /uk/ (fallback) |
โ |
/uk/)# Test different countries
curl -I -H "X-Test-Country: DE" http://localhost:8080/
curl -I -H "X-Test-Country: US" http://localhost:8080/
curl -I -H "X-Test-Country: JP" http://localhost:8080/ # Unknown country
# Test Google Bot exception
curl -I -A "Googlebot/2.1" http://localhost:8080/
# Test protected areas
curl -I -H "X-Test-Country: DE" http://localhost:8080/wp-admin/
curl -I -H "X-Test-Country: DE" http://localhost:8080/robots.txt
# Test with query parameters
curl -I "http://localhost:8080/?country=FR"
curl -I "http://localhost:8080/?country=AU"
# Real-time logs
docker-compose logs -f htaccess-tester
# Apache access logs (with country info)
docker-compose exec htaccess-tester tail -f /var/log/apache2/access.log
# Apache error logs
docker-compose exec htaccess-tester tail -f /var/log/apache2/error.log
The server adds debug headers to help troubleshoot:
X-Debug-Country: Shows detected country codeX-Debug-Query: Shows query string# Access container shell
docker-compose exec htaccess-tester bash
# Check .htaccess syntax
docker-compose exec htaccess-tester apache2ctl configtest
# View current .htaccess
docker-compose exec htaccess-tester cat /var/www/html/.htaccess
๐ Docker Environment
โโโ ๐ณ Dockerfile - Apache + PHP setup
โโโ โ๏ธ docker-compose.yml - Service orchestration
โโโ ๐ apache-vhost.conf - Apache configuration with GeoIP mock
โโโ ๐งช geoip-mock.php - Interactive testing interface
โโโ ๐ test-scripts/
โ โโโ test-countries.sh - Automated test script
โโโ ๐ .htaccess - Your actual .htaccess file (mounted)
โโโ ๐ logs/ - Apache logs (mounted volume)
ports:
# Check if file is mounted correctly
docker-compose exec htaccess-tester ls -la /var/www/html/.htaccess
# Restart container after .htaccess changes
docker-compose restart htaccess-tester
# Check Apache error logs
docker-compose logs htaccess-tester
# Verify mod_rewrite is enabled
docker-compose exec htaccess-tester apache2ctl -M | grep rewrite
# Stop and remove containers
docker-compose down
# Remove images (optional)
docker-compose down --rmi all
# Remove volumes (optional)
docker-compose down -v