I have an issue redirecting from the http site to the https site.
This index.php file is in the root folder, redirecting to a suburl:
<?php
header("Location: /news/");
?>
the url https://www.example.com
is correctly redirecting to https://www.example.com/news/
the url https://www.example.com/index.php
is correctly redirecting to https://www.example.com/news/
the url http://www.example.com/index.php
is correctly redirecting to https://www.example.com/news/
however the url http://www.example.com
is showing an empty directory, as in the image below:
these are the config files:
/etc/apache2/sites-available/www.example.com.conf
<VirtualHost *:*>
ServerName www.example.com
DocumentRoot /var/www/vhosts/example.com/httpdocs
ServerAlias example.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
/etc/apache2/sites-available/www.example.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.example.com
DocumentRoot /var/www/vhosts/example.com/httpdocs
ServerAlias example.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
How can I correctly redirect from http://www.example.com
to https://www.example.com/news/
?