# ─────────────────────────────────────────────────────────────────────────────
# SellZaki Apache VirtualHost — Image / Storage Fix
# ─────────────────────────────────────────────────────────────────────────────
#
# PROBLEM: /storage/ symlink returns 403 because Apache requires:
#   1. Options +FollowSymLinks  (to traverse symlinks)
#   2. AllowOverride All        (so .htaccess is respected)
#
# The fix is applied in two places:
#   A) public/.htaccess  — already updated to include +FollowSymLinks
#   B) VirtualHost config — must have AllowOverride All
#
# Place this file at: /etc/apache2/sites-available/sellzaki.conf
# Then enable: sudo a2ensite sellzaki && sudo systemctl reload apache2
# ─────────────────────────────────────────────────────────────────────────────

<VirtualHost *:80>
    ServerName sellzaki.com
    ServerAlias www.sellzaki.com *.sellzaki.com
    Redirect permanent / https://sellzaki.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName sellzaki.com
    ServerAlias www.sellzaki.com *.sellzaki.com

    DocumentRoot /var/www/html/sellzaki.com/production/public

    # ── CRITICAL: Allow .htaccess to work and symlinks to be followed ─────────
    <Directory /var/www/html/sellzaki.com/production/public>
        Options +FollowSymLinks -MultiViews -Indexes
        AllowOverride All
        Require all granted
    </Directory>

    # ── Also allow traversal into the storage directory ───────────────────────
    <Directory /var/www/html/sellzaki.com/production/storage>
        Options +FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    # ── SSL ───────────────────────────────────────────────────────────────────
    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/sellzaki.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/sellzaki.com/privkey.pem

    # ── Logging ───────────────────────────────────────────────────────────────
    ErrorLog  ${APACHE_LOG_DIR}/sellzaki-error.log
    CustomLog ${APACHE_LOG_DIR}/sellzaki-access.log combined
</VirtualHost>
