# Custom URL routing configuration
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    
    # Enable compression for text files
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
    </IfModule>
    
    # Set caching headers for static assets
    <FilesMatch "\\.(ico|pdf|jpg|jpeg|png|gif|js|css|svg)$">
        Header set Cache-Control "max-age=86400, public"
    </FilesMatch>
</Directory>

# Alias for /blog to serve from the blog directory
Alias "/blog" "/var/www/html/blog"

# Configure DirectoryIndex for both root and blog directory
<LocationMatch "^/$">
    DirectoryIndex index.html
</LocationMatch>

<LocationMatch "^/blog/?$">
    DirectoryIndex index.html
</LocationMatch>

# Custom error pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

# Enable .html extension to be optional
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # For URLs like /blog/hello-world (without .html)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.+)$ .html [L,QSA]
</IfModule>
