# IQON Static Deployment — .htaccess for reg.ru shared hosting
# Replaces WordPress routing with static file serving + 301 redirects
# Created: 2026-05-20
# Updated: 2026-05-20

# ── Prefer static entrypoint while WordPress files remain for rollback ──
DirectoryIndex index.html index.php

# ── Security headers ──────────────────────────────────────────────
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
    Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'; base-uri 'self'; frame-ancestors 'self'"
</IfModule>

# ── Rewrite engine ───────────────────────────────────────────────
<IfModule mod_rewrite.c>
    RewriteEngine On

    # ── Canonical host ────────────────────────────────────────
    RewriteCond %{HTTP_HOST} ^www\.iqon\.com$ [NC]
    RewriteRule ^ https://iqon.com%{REQUEST_URI} [L,R=301]

    # ── Block WordPress surfaces ──────────────────────────────
    RewriteRule ^wp-json/ - [F,L]
    RewriteRule ^xmlrpc\.php$ - [F,L]
    RewriteRule ^wp-login\.php$ - [F,L]

    # ── Block WordPress files ─────────────────────────────────
    RewriteRule ^readme\.html$ - [F,L]
    RewriteRule ^license\.html$ - [F,L]
    RewriteRule ^wp-config\.php$ - [F,L]

    # ── Domain redirects (from original .htaccess) ─────────────
    RewriteCond %{HTTP_HOST} ^iqon\.md$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.iqon\.md$
    RewriteRule ^/?$ https://www.iqon.com/ [R=301,L]

    RewriteCond %{HTTP_HOST} ^iqonrussia\.kz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.iqonrussia\.kz$
    RewriteRule ^/?$ https://www.iqon.com/ [R=301,L]

    RewriteCond %{HTTP_HOST} ^iqonrussia\.ru$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.iqonrussia\.ru$
    RewriteRule ^/?$ https://www.iqon.com/ [R=301,L]

    # ── Homepage aliases → / ──────────────────────────────────
    RewriteRule ^homepage/?$ / [R=301,L]
    RewriteRule ^hows-business/?$ / [R=301,L]

    # ── Old service URLs → new /services/ structure ────────────
    RewriteRule ^services-solutions/?$ /services/ [R=301,L]

    # Enterprise Management & Decision Support → Strategy & Governance / Data & Analytics
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/?$ /services/strategy-governance/ [R=301,L]
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/managed-services/?$ /services/strategy-governance/ [R=301,L]
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/enterprise-orchestration/?$ /services/strategy-governance/ [R=301,L]
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/enterprise-management-systems/?$ /services/strategy-governance/ [R=301,L]
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/customer-intelligence-solutions/?$ /services/data-analytics/ [R=301,L]
    RewriteRule ^services-solutions/enterprise-management-decision-support-solutions/enterprise-information-management/?$ /services/data-analytics/ [R=301,L]

    # IS Advisory → Enterprise Architecture / Strategy & Governance / Security
    RewriteRule ^services-solutions/is-advisory-services/?$ /services/enterprise-architecture/ [R=301,L]
    RewriteRule ^services-solutions/is-advisory-services/business-technology-enterprise-architecture/?$ /services/enterprise-architecture/ [R=301,L]
    RewriteRule ^services-solutions/is-advisory-services/it-strategy-governance/?$ /services/strategy-governance/ [R=301,L]
    RewriteRule ^services-solutions/is-advisory-services/information-security-services/?$ /services/security-continuity/ [R=301,L]
    RewriteRule ^services-solutions/is-advisory-services/business-continuity-and-disaster-recovery-planning-services/?$ /services/security-continuity/ [R=301,L]
    RewriteRule ^services-solutions/is-advisory-services/is-regulatory-and-compliance-services/?$ /services/security-continuity/ [R=301,L]

    # IT Infrastructure → Infrastructure & Cloud
    RewriteRule ^services-solutions/it-infrastructure-services/?$ /services/infrastructure-cloud/ [R=301,L]
    RewriteRule ^services-solutions/it-infrastructure-services/infrastructure-management-consulting/?$ /services/infrastructure-cloud/ [R=301,L]
    RewriteRule ^services-solutions/it-infrastructure-services/it-infrastructure-transformation-services/?$ /services/infrastructure-cloud/ [R=301,L]
    RewriteRule ^services-solutions/it-infrastructure-services/end-user-computing-technology-solutions/?$ /services/infrastructure-cloud/ [R=301,L]

    # Mobility → Enterprise Architecture / Infrastructure & Cloud
    RewriteRule ^services-solutions/mobility-consulting-services/?$ /services/enterprise-architecture/ [R=301,L]
    RewriteRule ^services-solutions/mobility-consulting-services/mobility-software-services-applications/?$ /services/enterprise-architecture/ [R=301,L]
    RewriteRule ^services-solutions/mobility-consulting-services/mobility-managed-services/?$ /services/enterprise-architecture/ [R=301,L]
    RewriteRule ^services-solutions/mobility-consulting-services/mobility-software-services-devices-and-platforms/?$ /services/infrastructure-cloud/ [R=301,L]
    RewriteRule ^services-solutions/mobility-consulting-services/mobility-business-integration-services/?$ /services/enterprise-architecture/ [R=301,L]

    # Industry Specific → /industries/
    RewriteRule ^services-solutions/industry-specific-services/?$ /industries/ [R=301,L]
    RewriteRule ^industry-specific-services/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/retail-wholesail/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/retail-wholesale/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/logistics-transport/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/telecommunication/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/energy-utilities/?$ /industries/ [R=301,L]
    RewriteRule ^services-solutions/industry-specific-services/manufacturing-process/?$ /industries/ [R=301,L]

    # Contact
    RewriteRule ^contact-kz/?$ /contact/ [R=301,L]

    # ── Russian URLs → English (EN-only policy) ─────────────────
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/?$ /services/ [R=301,L,NE]
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/enterprise-management-decision-support-solutions/?$ /services/strategy-governance/ [R=301,L,NE]
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/it-infrastructure-services/?$ /services/infrastructure-cloud/ [R=301,L,NE]
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/industry-specific-services/?$ /industries/ [R=301,L,NE]
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/mobility-consulting-services/?$ /services/enterprise-architecture/ [R=301,L,NE]
    RewriteRule ^%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/is-advisory-services/?$ /services/enterprise-architecture/ [R=301,L,NE]
    # Catch-all for remaining Russian subpaths
    RewriteCond %{REQUEST_URI} ^/%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B8-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F/
    RewriteRule .* /services/ [R=301,L,NE]

    # ── Custom error pages ─────────────────────────────────────
    ErrorDocument 404 /404.html
    ErrorDocument 403 /403.html
</IfModule>

# ── Caching ──────────────────────────────────────────────────────
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html "access plus 1 hour"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 month"
    ExpiresByType application/xml "access plus 1 hour"
</IfModule>

# ── Block directory listings ─────────────────────────────────────
Options -Indexes

# ── Protect sensitive files ──────────────────────────────────────
<FilesMatch "^(wp-config|\.htaccess|\.env)">
    Require all denied
</FilesMatch>
