Warning |
---|
Quick notes and needs to be flushed out and tested. |
Introduction
Different ways of doing this. Complete rewrite or file based. We'll cover both but the recommended approach is to use rewrite which covers not just the main index file but all scenarios.
...
Note |
---|
Further reading from Apache seems to say this Rewrite is NOT the right approach and to use Redirect instead, A common use for RewriteRule is to redirect an entire class of URLs. For example, all URLs in the /one directory must be redirected to http://one.example.com/, or perhaps all http requests must be redirected to https. These situations are better handled by the Redirect directive. Remember that Redirect preserves path information. That is to say, a redirect for a URL /one will also redirect all URLs under that, such as /one/two.html and /one/three/four.html. BUT all over the internet people recommend Rewrite... |
Switch HTTP to HTTPS using Redirect
According to what I've read when redirecting everything don't bother with a document root,
...
I've still to try and see if this impacts the entire site. Based on what I see I can't quite grasp how it would...
Switch
...
HTTP
...
to
...
HTTPS with Rewrite
...
Code Block |
---|
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] |
Switch HTTPS to HTTP with Rewrite
...
Code Block |
---|
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} |
References
https://wp-mix.com/htaccess-redirect-http-to-https/
...