0

I have an existing static web-app on S3 behind CloudFront, let's say at example.com

I want to add a WordPress blog, which should be accessed at example.com/blog

For the WordPress blog, i've set up an ec2 server with Apache and WordPress.

I've added the ec2 server as origin in CloudFront as describe here.

When i'm running:

curl example.com/blog

i'm getting:

<!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>

For that reason, I think my problem is not in CloudFront but in the configuration of the Apache server.

My question is: how to configure Apache to work this way?

meaning as sub-directory

Arnon
  • 163
  • 1
  • 5

1 Answers1

0

When Apache knows it will tell a browser 301 Moved Permanently it uses the ServerName which you specified on <VirtualHost> level or on global level.

If you don't set a ServerName it tries to find out a FQDN by a heuristic (a reverse DNS query for one of IP addresses) and a typical sad result is what you get.

Examples:

ServerName example.com
ServerName http://example.com
ServerName https://example.com:8443
kubanczyk
  • 13,812
  • 5
  • 41
  • 55