force virtual server web site to use SSL


what is the best way to force an web site to use https:// and not http:// ?
I was thinking about a redirect, but users can modify the URL and just remove the httpS:// when redirected
and they will be able to log-in without encryption, this is something I do not like.

Any idea ?

Thank You

If you do an http redirect with apache mod_rewrite, then users wouldn’t be able to remove the S. Same method can be also used to redirect a to (to avoid duplicate links for example).

thank You for reply, I think I understand what You mean, but still not sure how to fix it.
Can this be done from Virtualmin ?

as far as I know, perhaps this config will do it ?

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]


but how the manually created .htaccess will affect the Virtualmin ?

I added the following config in the .htaccess file and it`s working just fine, the user is not able to remove the httpS:// because once he do it the redirect will take him back to https:// …

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]

So the config above is tested and working just fine !



You’re quite welcome to use a .htaccess file to do that – it’s a good way to solve that problem.

I’m glad you got that working for you!


thanks a lot pal,

BUT one suggestion :slight_smile: You could also make it possible to edit .htaccess files from Virtualmin
perhaps something called “Create Cuscom .htaccess file” and open the web form where we can type the rewrite domains etc … :slight_smile:


This here solved it for me.

Force the website (virtual server) to use https (SSL) instead of http. Under

Virtualmin --> Services --> Configure Website --> Edit Directives

bei RewriteEngine On

Folgendes einfügen

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$$1 [R,L]

(Der Schrägstrich zwischen Domain und $1 musste bei mir auch noch weg, sonst gab es doppelte Schrägstriche in Domain.)
Das Ganze kann auch in einer .htaccess hinterlegt werden.

Don’t forget to reload/restart Apache so that the changes become effective. (button upper right corner…)

Virtualmin --> Services --> Configure Website --> Edit Directives

RewriteEngine On

RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [R]

Restart Apache


Thanks dude.

VM being a GUI ( graphical user interface ) needs a click for that function otherwise what is the point ??