# Brand Domain Tracking Files Configuration
# This file ensures tracking endpoints (o.php, c.php, u.php) work with both HTTP and HTTPS

<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # Base rewrite rule
    RewriteBase /
    
    # Do NOT redirect tracking files to HTTPS
    # Allow them to be accessed via both HTTP and HTTPS
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} (o|c|u)\.php$ [NC]
    RewriteRule ^ - [L]
    
    # If there's a general HTTPS redirect rule, make sure tracking files bypass it
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !(o|c|u)\.php$ [NC]
    # This allows other rules to apply, but skips HTTPS redirect for tracking files
</IfModule>

# Prevent directory listing
Options -Indexes

# Ensure PHP files can be executed
<FilesMatch "\.(php)$">
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Allow,Deny
        Allow from all
    </IfModule>
</FilesMatch>

# Set proper MIME types
<IfModule mod_mime.c>
    AddType application/x-httpd-php .php
</IfModule>