# ###########################################################################
# INAKTIV auf dem aktuellen Host - aber inhaltlich wieder korrekt.
# ###########################################################################
#
# Diese Datei wird live nie gelesen: top10-mannheim.de laeuft auf RENDER
# (.github/workflows/deploy.yml stoesst einen Render-Deploy-Hook an,
# Cloudflare steht nur als CDN davor). Render liest kein .htaccess.
# Was live wirkt, sind die statischen Meta-Refresh-Stubs unter public/
# (z. B. public/apotheken/index.html); public/_redirects und die routes in
# render.yaml sind ebenfalls wirkungslos - siehe die Koepfe dort.
#
# Bereinigt am 23.09.2026: Die Datei war aus heidelberg-interaktiv kopiert.
# 349 der 359 Regeln waren Heidelberg-301er - URLs, die es auf
# top10-mannheim.de nie gab, auf Ziele, die hier nicht existieren
# (/branchenbuch/ fehlt komplett, unter /blog/ liegen zwei Artikel).
# Gemessen: 328 der 336 Slug-Regeln zeigten in einen 404. Ein Beispiel war
# /schachclub-gemmingen/ -> /blog/schachclub-gemmingen/: die Quellseite
# existiert, das Ziel nie (Quelldatei liegt in _legacy-heidelberg/, und
# Astro ignoriert _-Ordner) - ein 301 mitten in einen 404.
#
# Stehen geblieben ist nur, was dieser Domain gehoert: HTTPS-Zwang,
# www -> Apex, der Bot-Block und die /r/-Affiliate-Gates, 404-Seite,
# GZIP, Browser-Cache, Security-Header. Bei einem Wechsel auf Apache/
# Hostinger ist die Datei damit direkt verwendbar.
#
# Echte Legacy-301er fuer top10-mannheim.de gehoeren hier neu erfasst -
# aus einem Export DIESER Domain, nicht aus einem Schwesterprojekt.
#
# ###########################################################################

# =================================================================
# Top10-Mannheim - Apache .htaccess für Hostinger
# =================================================================

# --- HTTPS erzwingen --------------------------------------------------
RewriteEngine On

# ============================================================
# Bot-Block auf den Affiliate-Redirects (/r/)
# Bots folgen die 302 auf awin1.com; AWIN zaehlt JEDEN Hit als Klick.
# Messung 01.-23.07.2026: bis 66 % Klicks je GA4-Session, 5 Sales auf 2.052 Klicks.
# Greift NUR auf /r/ und /go/ (Outbound-Gate) - der Content bleibt fuer alle Crawler erreichbar,
# ein False-Positive kostet also hoechstens einen Partnerlink, nie Indexierung.
# ============================================================
RewriteCond %{HTTP_USER_AGENT} (crawl|spider|slurp|scraper|archiver|indexer) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (curl/|wget|python-|go-http|java/|okhttp|libwww|scrapy|axios|node-fetch|guzzle|httpclient) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (headlesschrome|phantomjs|puppeteer|playwright|selenium) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (zgrab|masscan|nmap|nikto|sqlmap|wpscan|censys|nuclei|acunetix|netsparker|qualys) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|yandexbot|duckduckbot|applebot|seznambot|exabot) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (ahrefsbot|semrushbot|mj12bot|dotbot|blexbot|petalbot|seokicks|sistrix|serpstatbot|dataforseo|majestic|sitebulb|seobility|netcraft|screaming) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (gptbot|chatgpt|oai-searchbot|ccbot|claudebot|claude-web|anthropic|perplexity|amazonbot|bytespider|meta-externalagent|google-extended|diffbot|omgili|timpibot|youbot|imagesift|cohere) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit|twitterbot|linkedinbot|whatsapp|telegrambot|slackbot|discordbot|pinterest|redditbot) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^(r|go)/ - [F,L]

# ---- Affiliate-Redirects (/r/...) 302, clickref = top10-mannheim.de (AWIN 514869) ----
RewriteRule ^r/docmorris(-10euro)?/?$ https://www.awin1.com/cread.php?s=2490784&v=14485&q=372737&r=514869&clickref=top10-mannheim.de [R=302,L,NE]
RewriteRule ^r/shop-apotheke(-rezept)?/?$ https://www.awin1.com/cread.php?s=3450028&v=13808&q=471107&r=514869&clickref=top10-mannheim.de [R=302,L,NE]
RewriteRule ^r/mediherz(-gutscheine)?/?$ https://www.awin1.com/cread.php?s=2269210&v=11630&q=348918&r=514869&clickref=top10-mannheim.de [R=302,L,NE]
RewriteRule ^r/medpex(-zuzahlungsfrei)?/?$ https://www.awin1.com/awclick.php?gid=447437&mid=36320&awinaffid=514869&linkid=3237938&clickref=top10-mannheim.de [R=302,L,NE]
RewriteRule ^r/fliegende-pillen/?$ https://www.awin1.com/cread.php?s=3450028&v=13808&q=471107&r=514869&clickref=top10-mannheim.de [R=302,L,NE]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# --- www auf non-www zusammenführen (top10-mannheim.de) -------
RewriteCond %{HTTP_HOST} ^www\.top10-mannheim\.de$ [NC]
RewriteRule ^(.*)$ https://top10-mannheim.de/$1 [L,R=301]


# --- 404-Page einbinden ---------------------------------------------
ErrorDocument 404 /404/index.html

# --- GZIP / Deflate-Kompression -------------------------------------
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
  AddOutputFilterByType DEFLATE application/javascript application/json application/xml
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

# --- Browser-Cache --------------------------------------------------
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html "access plus 5 minutes"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/jpeg "access plus 6 months"
  ExpiresByType image/png "access plus 6 months"
  ExpiresByType image/svg+xml "access plus 6 months"
  ExpiresByType image/webp "access plus 6 months"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

# --- Security-Header ------------------------------------------------
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
  Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
</IfModule>
