Define SRVROOT "{{SRVROOT}}"
ServerRoot "${SRVROOT}"

Listen {{LISTEN_ADDRESS}}:{{PORT}}

# Temel Modüller
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so
LoadModule alias_module modules/mod_alias.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule actions_module modules/mod_actions.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
# Önerilen Ek Modüller
LoadModule headers_module modules/mod_headers.so
LoadModule env_module modules/mod_env.so
LoadModule deflate_module modules/mod_deflate.so

# Windows optimizations
AcceptFilter http none
AcceptFilter https none

# Required for PHP-FPM on Windows
<IfModule proxy_fcgi_module>
    ProxyFCGIBackendType GENERIC
    # Fix for encoded spaces and special characters in Windows paths
    SetEnv proxy-fcgi-pathinfo unescape
</IfModule>

ServerAdmin admin@localhost
ServerName localhost:{{PORT}}

# MIME Types (Kritik)
TypesConfig conf/mime.types

# Ana Güvenlik Kuralı (Tüm disk erişimini kapat)
<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "{{ROOT}}"
<Directory "{{ROOT}}">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    CGIPassAuth On
</Directory>

ErrorLog "{{LOG_DIR}}/apache_error.log"
LogLevel warn proxy_fcgi:trace8

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    CustomLog "{{LOG_DIR}}/apache_access.log" common
</IfModule>

<IfModule dir_module>
    DirectoryIndex index.php index.html index.htm
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

# phpMyAdmin configuration
Alias /phpmyadmin "{{PHPMYADMIN_DIR}}"
<Directory "{{PHPMYADMIN_DIR}}">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    CGIPassAuth On
</Directory>

# Project configurations
{{PROJECTS}}

# Global PHP handler (Manual Nginx-Style SCRIPT_FILENAME)
# Inspired by Nginx's fastcgi_param SCRIPT_FILENAME $request_filename.
<FilesMatch "\.php$">
    SetHandler "proxy:fcgi://127.0.0.1:{{PHP_PORT}}/"
    <IfModule rewrite_module>
        RewriteEngine On
        # Explicitly set the physical path to avoid broken automatic mapping on Windows
        RewriteRule . - [E=proxy-fcgi-pathinfo:%{REQUEST_FILENAME}]
    </IfModule>
</FilesMatch>

