Apacheをサブディレクトリとして使用してWordpressブログをホストする

Apacheをサブディレクトリとして使用してWordpressブログをホストする

私はCloudFrontの背後にあるS3に静的ウェブアプリを既に持っています。example.com

WordPressブログを追加したいのですが、次のURLにアクセスする必要があります。example.com/blog

WordPress ブログ用に、Apache と WordPress を備えた ec2 サーバーをセットアップしました。

説明したように、CloudFrontのオリジンとしてec2サーバーを追加しましたここ

走っているとき:

curl example.com/blog

私が得ているのは:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://ec2-x-x-x-x.us-west-1.compute.amazonaws.com/blog/">here</a>.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at http://ec2-x-x-x-x.us-west-1.compute.amazonaws.com Port 80</address>
</body></html>

そのため、問題は CloudFront ではなく、Apache サーバーの設定にあると思います。

私の質問は、Apache をこのように動作させるにはどうすればいいかということです。

サブディレクトリとしての意味

答え1

Apache がブラウザに 301 Moved Permanently を通知することを認識すると、レベルまたはグローバル レベルでServerName指定されたものが使用されます。<VirtualHost>

を設定しないと、ServerNameヒューリスティック (IP アドレスの 1 つに対する逆 DNS クエリ) によって FQDN を見つけようとし、典型的な残念な結果が返されます。

例:

ServerName example.com
ServerName http://example.com
ServerName https://example.com:8443

関連情報