highball.se

Out of clutter, find simplicity

Enforce HTTPS with a .htaccess file

Start by enabling mod_rewrite then create an .htaccess file in the directory that you want to force HTTPS.

The content of the .htaccess-file:

RewriteEngine On RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

Now if you go to http://www.domain.com/somefolder you will be redirected to https://www.domain.com/somefolder.


Categorised as: Apache


Comments are closed.