Apache: Permanent Redirect to HTTPS with Wildcard Apache: Permanent Redirect to HTTPS with Wildcard apache apache

Apache: Permanent Redirect to HTTPS with Wildcard


As RedirectMatch Directive of Apache 2.4 httpd says:

Syntax: RedirectMatch [status] regex URL

This directive is equivalent to Redirect, but makes use of regular expressions, instead of simple prefix matching.

Example:

RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg"

Apache uses PCRE compatible regexp's.

But normally it should be enought to use:

Redirect permanent / https://www.example.com/

Last but not least the important part: Redirect only matches URL-path and not the complete URL!

So you better add a VirtualHost configuration for every subdomain you are using.