Apache redirect HTTP to HTTPS Redirect or Rewrite?

The official documentation on When not to use mod_rewrite lists Simple Redirection and also gives your HTTP to HTTPS as an example:

mod_alias provides the Redirect and RedirectMatch directives, which provide a means to redirect one URL to another. This kind of simple redirection of one URL, or a class of URLs, to somewhere else, should be accomplished using these directives rather than RewriteRule. RedirectMatch allows you to include a regular expression in your redirection criteria, providing many of the benefits of using RewriteRule.

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.

Your RewriteRule example might be a necessary hack if one only has access to single configuration section that handles both HTTP and HTTPS. That is common when there are .htaccess files involved e.g. on a shared hosting. That is another story; When (not) to use .htaccess files.


They do the same thing. Redirect is simpler, easier to read, and doesn't require mod_rewrite, so it's better to use it unless you need something it can't do.