RedirectMatchがホスト名と一致します。

RedirectMatchがホスト名と一致します。

Apache 2.4を使用しています。

すべてのHTTPトラフィックをapexドメインの標準ドメインと一致するHTTPSにリダイレクトしたいと思います。 RewriteRulesを介してこれを行うことができることを知っていますが、代わりにHTTPヘッダーからドメイン名を取得するRedirectMatchを使用したいと思います。

ServerName exampledomain.com
ServerAlias *.exampledomain.com
<If "%{SERVER_PROTOCOL} != 'HTTPS'">
RedirectMatch (.*) "https://%{HTTP_HOST}$1"
</If>

したがって、要求するとhttp://anynameyoucanimagine.exampledomain.comにリダイレクトされますhttps://anynameyoucanimagine.exampledomain.com

どんなアイデアがありますか?

ありがとうございます!

ベストアンサー1

次の行は十分簡単です。

ServerName anynameyoucanimagine.exampledomain.com
RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1

おすすめ記事