This is a canonical question about redirecting from http to https in Apache
Related:
I have an Appache web server which serves both http://example.com/ and https://example.com/. I want to redirect all http requests to https. Currently I'm using this .htaccess rule to redirect http requests to https.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
It's working as expected for example.com but the same rule is not working for sub links, when I access existing links, like example.com/about it will still load in http, no redirection happens for existing links.
How can I make Apache redirect all http requests to https?
NameVirtualHostline is no longer needed in current Apache versions. See https://serverfault.com/q/735233/214507 – kasperd Jan 22 '19 at 18:30ServerName www.example.com example.com" - It's not valid to have mutliple server names / arguments with theServerNamedirective. Maybe you're thinking of theServerAliasdirective? – MrWhite Oct 16 '19 at 20:07