Category Archives: Apache

Apache

CLI

# Enable modules
a2enmod ssl
a2enmod rewrite

# Disable autoindex
a2dismod autoindex

# Enable default SSL config
a2ensite default-ssl

Configuration

# HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}

Quick steps to enable mod_rewrite in Linux apache2

Apache2 does not have mod_rewrite turned on by default. Fortunately there are just a few steps to get this functionality working.

First activate rewrite engine using the following command.

a2enmod rewrite

Then allow override in the site configuration file on Apache. In my case I am testing it on a development machine, so I will edit the main file

sudo gedit /etc/apache2/sites-enabled/default.

by changing AllowOverride from None to All.


<Directory /mnt/Personal/Web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

At the end Restart apache2.

sudo /etc/init.d/apache2 restart