Index: src/puppetcode/environments/gnuboat/modules/gnuboat_mapservice/manifests/apache_config.pp
===================================================================
--- src/puppetcode/environments/gnuboat/modules/gnuboat_mapservice/manifests/apache_config.pp	(revision e6aa6a3c5b14f0de908e9b0db3eb3c4b0151a518)
+++ src/puppetcode/environments/gnuboat/modules/gnuboat_mapservice/manifests/apache_config.pp	(revision a8965fbe02603318c95985eb7ce43b8b3d94b4e4)
@@ -1,35 +1,59 @@
 class gnuboat_mapservice::apache_config inherits gnuboat_mapservice
 {
-	# Configure apache, if wanted
-        if($apache_enabled){
-                if empty($apache_vhost_ssl_cert) and empty($apache_vhost_ssl_key) {
-                        apache::vhost{$apache_vhost_name:
-                                servername => $apache_vhost_servername,
-                                port => '80',
-                                docroot => '/var/www',
-                                proxy_pass => [
-                                        { path => '/', url => 'http://localhost:8080/' },
-                                ],
-                                suphp_engine => off,
-                        }
-                } else {
-                        apache::vhost{$apache_vhost_name:
-                                servername => $apache_vhost_servername,
-                                port => '443',
-                                docroot => '/var/www',
-                                proxy_pass => [
-                                        { path => '/', url => 'http://localhost:8080/' },
-                                ],
-                                suphp_engine => off,
-                                ssl => true,
-                                ssl_cert => $apache_vhost_ssl_cert,
-                                ssl_key => $apache_vhost_ssl_key,
-                        }
-                }
+    # Configure apache, if wanted
+    if($apache_enabled){
+        # install and enable mod rewrite
+        apache::mod { 'rewrite': }
+        if empty($apache_vhost_ssl_cert) and empty($apache_vhost_ssl_key) {
+            apache::vhost{$apache_vhost_name:
+                servername => $apache_vhost_servername,
+                port => '80',
+                docroot => '/var/www/gnuboat_mapservice_webclient',
+                proxy_pass => [
+                    { path => '/mapservice', url => 'http://localhost:8080/mapservice' },
+                    { path => '/osm_tiles', url => 'http://localhost:8081/' },
+                ],
+                rewrites => [
+                    {
+                        rewrite_base =>  '/',
+                        rewrite_cond => ['%{THE_REQUEST} !\s/+(mapservice|osm_tiles)/ [NC]'],
+                        rewrite_cond => ['%{REQUEST_FILENAME} !-d'],
+                        rewrite_cond => ['%{REQUEST_FILENAME} !-f'],
+                        rewrite_cond => ['%{THE_REQUEST} !^/resources/(.+)$'],
+                        rewrite_rule => ['^(.+)$ index.html?path=$1 [L]'],
+                    },
+                ]
+                suphp_engine => off,
+            }
+        } else {
+            apache::vhost{$apache_vhost_name:
+                servername => $apache_vhost_servername,
+                port => '443',
+                docroot => '/var/www/gnuboat_mapservice_webclient',
+                proxy_pass => [
+                    { path => '/mapservice', url => 'http://localhost:8080/mapservice' },
+                    { path => '/osm_tiles', url => 'http://localhost:8081/' },
+                ],
+                rewrites => [
+                    {
+                        rewrite_base =>  '/',
+                        rewrite_cond => ['%{THE_REQUEST} !\s/+(mapservice|osm_tiles)/ [NC]'],
+                        rewrite_cond => ['%{REQUEST_FILENAME} !-d'],
+                        rewrite_cond => ['%{REQUEST_FILENAME} !-f'],
+                        rewrite_cond => ['%{THE_REQUEST} !^/resources/(.+)$'],
+                        rewrite_rule => ['^(.+)$ index.html?path=$1 [L]'],
+                    },
+                ]
+                suphp_engine => off,
+                ssl => true,
+                ssl_cert => $apache_vhost_ssl_cert,
+                ssl_key => $apache_vhost_ssl_key,
+            }
+        }
 
-                if($apache_replace_default_host){
-                        class {'apache': default_vhost => false,
-                        }
-                }
+        if($apache_replace_default_host){
+            class {'apache': default_vhost => false,
+            }
         }
+    }
 }
