Hi I am a web designer and have recently starting maintaining a VPS server
I am using a Lamp VPS server running ubuntu 18 with multiple PHP websites
have edited virtual host and htaccess multiple times.
Problem :
1.in all websites: all "www version of websites" redirecting to apache homepage
2.non-https version not redirecting to https version
Should I reissue ssl cert for www version seperately ?
Code for Virtual Hosts
<VirtualHost *:80>
ServerName www.temp.com
ServerAlias temp.com
Redirect "/" "https://www.temp.com"
DocumentRoot /var/www/temp.com/
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,END]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,END]
</VirtualHost>
Code for .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
I am using Certbot for SSL certificates using
sudo certbot --apache