Environment Centos with apache
Trying to setup automatic redirection from http to https
From manage.mydomain.com --- To ---> https://manage.mydomain.com
I have tried adding the following to my httpd.conf but it didn't work
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
Any ideas?
Searched for
apache redirect http to https
and landed here. This is what i did on ubuntu:1) Enable modules
2) Edit your site config
Edit file
Content should be:
3) Restart apache2
Server version: Apache/2.4.29 (Ubuntu)
After long search on the web and in the official documentation of apache, the only solution that worked for me came from /usr/share/doc/apache2/README.Debian.gz
In the file /etc/apache2/sites-available/000-default.conf add the
That's it.
P.S: If you want to read the manual without extracting:
This code work for me.
If you have Apache2.4 check
000-default.conf
- removeDocumentRoot
and addThis worked for me:
Actually, your topic is belongs on https://serverfault.com/ but you can still try to check these .htaccess directives: