Force https usage on my webpage

New to Debian (Or Linux in general)? Ask your questions here!

Force https usage on my webpage

Postby Copernicus365 » 2020-11-22 20:22

I have added two .htaccess files (
Code: Select all
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
) to my webserver so that I can force https use. What I dont understand is why I need to add one .htaccess file in the html folder (standard public html apache2 directory) and another one for the forum folder "phpBB3". When I only added the .htaccess file for the public html folder, then forcing of https did not work on the folder (only on

So now I have two .htaccess files for enforcing https and the thought comes up, will I have to spam .htaccess files on different folders on this webserver or am I doing something wrong (one .htacess actually also worked for subfolders on a webhost that I tried on earlier)?
Posts: 6
Joined: 2020-11-19 17:32

Re: Force https usage on my webpage

Postby 5ive » 2020-12-18 04:27

When Apache serves content from a directory it will first check and respect any .htaccess file saved there.
The file only affects that directory and no other directory.

For enforcing HTTPS across the whole site it is better to place the configuration in the main configuration files.
I am rusty on Apache (I now use other software), but I know your main configuration files can have almost any configuration that lives in a .htaccess and it performs better (also less messy)

The official Apache guide is probably your best reference.
I do not take responsibility if you ruin your system.
Beginner’s Guide
Posts: 3
Joined: 2020-12-13 21:10

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 11 guests