'apache not redirecting http to https
my configuration file for redirecting http to https is not working. I have tried different options found in StackOverflow Apache virtual host redirect http to https
plus external resources like https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod-rewrite-for-apache-on-debian-10
the alias_mod and rewrite_mod are enabled (in the mods-enables folder) port 80 and 443 are enabled (in the ports.conf file) I have also tried with htacces in the project folder but I would rather not to use it
At the moment I have two conf files (one for the HTTP and the other for the https, as for default-guidelines conf files existing in the apache2 folder) The app works on BOTH https and HTTP but there is no redirect (not in the network in the development tools and I cannot get any info from the logs) The app has an internal redirect from "/" to the "/login" : I do not know if it can cause any issue
These are the conf files: 1- example.con
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /var/www/assets/eit_resource_manager_frontend/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RedirectMatch ^(.*)$ https://example.com$1
</VirtualHost>
2- example.ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /var/www/assets/eit_resource_manager_frontend/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
