Core Wiki

Table of Contents

Apache

.htaccess

Redirect requests to https

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

Rewrite domain.com/index.php?page=X routes as domain.com/X

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?page=$1 [QSA]

Virtual hosts

In order to redirect the www subdomain for a domain sternfoundation.org, one has to edit httpd-vhosts.conf

httpd-vhosts.conf
<VirtualHost *:80>
    ServerName www.sternfoundation.org
    Redirect permanent / https://sternfoundation.org
</VirtualHost>

To use SSL certificate on a domain www.sternfoundation.org in Apache one has to generate the certificate sternfoundation.crt and the key sternfoundation.key first.

httpd-vhosts.conf
<VirtualHost *:443>
    DocumentRoot "/home/bitnami/htdocs/.sternfoundation"
    ServerName www.sternfoundation.org
    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apache2/conf/sternfoundation.crt"
    SSLCertificateKeyFile "/opt/bitnami/apache2/conf/sternfoundation.key"
    <Directory "/home/bitnami/htdocs/.sternfoundation">
        AllowOverride All
        Order Allow,Deny
        Allow from all
        Require all granted    
    </Directory>
    # Other directives here
</VirtualHost>