Page tree
Skip to end of metadata
Go to start of metadata

Quick notes and needs to be flushed out and tested.


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.

There is a third scenario, which is if you having your CDN (Content Deliver Network) like Akamai host the redirects. The advantage with a CDN is the faster (done on the edge servers serving your content) and which also remove the load from your web servers.

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, 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,

NameVirtualHost *:80
<VirtualHost *:80>
   Redirect /

<VirtualHost _default_:443>
   DocumentRoot /usr/local/apache2/htdocs
   SSLEngine On
# etc...

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


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]


Shows using rewrite -