# PHP License Server - cPanel Configuration
# Works out of the box - no Python setup needed!

# Enable rewrite engine
RewriteEngine On

# Allow direct access to PHP files (bypass router)
# This must come FIRST before other rewrite rules
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^ - [L]

# Allow direct access to telegram_bot.php (for webhook)
RewriteCond %{REQUEST_URI} ^/license/telegram_bot\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/telegram_bot\.php$
RewriteRule ^ - [L]

# Route API requests to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*)$ index.php [QSA,L]

# Route other requests
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

# Security headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>

# Protect sensitive files
<FilesMatch "\.(db|json|log)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# PHP settings
<IfModule mod_php7.c>
    php_value upload_max_filesize 10M
    php_value post_max_size 10M
    php_value max_execution_time 300
    php_value max_input_time 300
</IfModule>
