Apache2 Skeleton

Skeleton to use with Apache2 configuration.


HTTP to HTTPS

<VirtualHost *:80>
    ServerName [vhost]
    ServerSignature Off

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

    ErrorLog ${APACHE_LOG_DIR}/[vhost].error.log
    CustomLog ${APACHE_LOG_DIR}/[vhost].access.log combined
</VirtualHost>
<VirtualHost *:443>
    ServerName [vhost]
    ServerSignature Off
    DocumentRoot /var/www/[vhost]

    SSLEngine On
    SSLCertificateFile      [/path/to/fullchain.pem]
    SSLCertificateKeyFile   [/path/to/key.pem]

    ErrorLog ${APACHE_LOG_DIR}/[vhost].error.log
    CustomLog ${APACHE_LOG_DIR}/[vhost].access.log combined
</VirtualHost>

Rewrite Rules

Rewrite Query String
RewriteEngine On
RewriteRule "^/path/index.htm[l]?$" "/path/index.php" [PT]
RewriteRule "^/path/((?!index.php).+)$" "/path/index.php?param=$1" [PT]