How would you replace this rewrite rule with a redirect?

Solution 1:

You cannot. Redirect is able to handle simple redirections, where you're sending the client to a single, specific name, but does not have the ability to do complex substitutions (setting aside the fact that %{HTTP_HOST} is mod_rewrite-specific).

Just stick with mod_rewrite. mod_alias isn't capable of doing what you need.

Solution 2:

As a followup, if you use Apache 2.4.19 or later, you can use a simpler format of Redirect within <Location> sections as detailed in the mod_alias documentation. This new format uses expression syntax, allowing the use of variables.

For example:

<VirtualHost *:80>
    ServerName lvh.me
    ServerAlias *.lvh.me

    <Location "/">
        Redirect "https://%{SERVER_NAME}%{REQUEST_URI}"
    </Location>
</VirtualHost>

Note that only the Redirect directive works with this shorter format, RedirectPermanent etc. do not.