Redirect all HTTP except openstreetmap.org straight to www
authorTom Hughes <tom@compton.nu>
Fri, 5 Oct 2018 14:02:04 +0000 (15:02 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 5 Oct 2018 14:02:04 +0000 (15:02 +0100)
cookbooks/web/templates/default/apache.frontend.erb

index 27a1b79b0760b8da0c593cbb831fe0a616eb0599..51d43a394d00d1088f53af8d8655ef955953ae1b 100644 (file)
 
 <VirtualHost *:80>
   ServerName openstreetmap.org
-  ServerAlias *
 
   Header always set Cache-Control "max-age=31536000"
   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
   RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
 </VirtualHost>
 
+<VirtualHost *:80>
+  ServerName www.openstreetmap.org
+  ServerAlias *
+
+  Header always set Cache-Control "max-age=31536000"
+  Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
+
+  RewriteEngine on
+
+  RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
+
+  RewriteCond %{REQUEST_URI} !^/server-status$
+  RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
+</VirtualHost>
+
 <VirtualHost *:443>
   ServerName openstreetmap.org
   ServerAlias *