# Apache Project Configuration (CGI Mode)
# Accessed via: http://localhost:{{PORT}}/{{HOST}}/

# 1. Alias definition (restores localhost/projectname access)
Alias /{{HOST}} "{{PATH}}"

# 2. ScriptAlias definition for the project's PHP CGI binary
# This maps a virtual URL path to the actual PHP folder.
ScriptAlias {{PHP_BIN_URL}}/ "{{PHP_DIR}}/"

# 3. Directory settings for the project
<Directory "{{PATH}}">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Require all granted
    
    # Passing Authorization header to PHP
    CGIPassAuth On
    
    # Directory index handling
    DirectoryIndex index.php index.html
    
    # PHP Handling via mod_actions and CGI
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php-{{HOST}}
    </FilesMatch>
    
    # Action maps the handler to the binary via the ScriptAlias URL
    # This is more robust on Windows than using absolute local paths.
    Action application/x-httpd-php-{{HOST}} "{{PHP_BIN_URL}}/php-cgi.exe"
</Directory>

# 4. Permissions for the PHP binary directory
<Directory "{{PHP_DIR}}">
    AllowOverride None
    Options None
    Require all granted
</Directory>