# Pass Authorization header to PHP
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule ^(.*) - [e=HTTP_AUTHORIZATION:%1]
</IfModule>

# Remove index from negotiation
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    # Remove www if present
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST:4}/$1 [R=301,L]

    # Don't rewrite if the request is for an existing file
    RewriteCond %{REQUEST_FILENAME} !-f
    # Don't rewrite if the request is for an existing directory
    RewriteCond %{REQUEST_FILENAME} !-d

    # Rewrite all requests to index.php
    RewriteRule ^ index.php [QSA,L]
</IfModule>

# Set index files
DirectoryIndex index.php

# Enable PHP error display (set to Off in production)
<IfModule mod_php.c>
    php_flag display_errors On
    php_flag display_startup_errors On
</IfModule>

# Allow access to all files
<FilesMatch "\.php$">
    Require all granted
</FilesMatch>

# Default content type
AddDefaultCharset UTF-8
