## LP20
RewriteRule ^/lichtparcours2020/?(.*)$ - [ENV=LP2020_SUBPATH:$1]

### redirects from plain path to german url
RewriteRule ^/lichtparcours2020/homepage/?$ /lichtparcours2020/ [R=302,L]
RewriteRule ^/lichtparcours2020/contact/?$ /lichtparcours2020/kontakt/ [R=302,L]
RewriteRule ^/lichtparcours2020/press/?$ /lichtparcours2020/presse/ [R=302,L]
RewriteRule ^/lichtparcours2020/sponsors/?$ /lichtparcours2020/unterstuetzer/ [R=302,L]
RewriteRule ^/lichtparcours2020/events/?$ /lichtparcours2020/veranstaltungen/ [R=302,L]
RewriteRule ^/lichtparcours2020/map/?$ /lichtparcours2020/karte/ [R=302,L]

### overlay gatsby over cms
RewriteCond %{ENV:LP2020_SUBPATH} ^.+$
RewriteCond "/var/www/braunschweig.de/apps/lichtparcours-2020-preview/public_live/%{ENV:LP2020_SUBPATH}" -f [OR]
RewriteCond "/var/www/braunschweig.de/apps/lichtparcours-2020-preview/public_live/%{ENV:LP2020_SUBPATH}" -d
RewriteRule ^/lichtparcours2020/?(.*)$ /var/www/braunschweig.de/apps/lichtparcours-2020-preview/public_live/$1 [L]

### redirect infosite preview to correct html url
#### artists
RewriteCond %{ENV:LP2020_SUBPATH} ^.+$
#RewriteCond %{HTTP_REFERER} ^https?://redaktion(-neu)?\.braunschweig\.de/ies/infosite6/\?openObjects=
RewriteRule ^/lichtparcours2020/artists/(.+)\.json$ /lichtparcours2020/karte/#$1 [NE,R,L]

#### blog posts
RewriteCond %{ENV:LP2020_SUBPATH} ^.+$
#RewriteCond %{HTTP_REFERER} ^https?://redaktion(-neu)?\.braunschweig\.de/ies/infosite6/\?openObjects=
RewriteRule ^/lichtparcours2020/blog-posts/(.+)\.json$ /lichtparcours2020/blog/#$1 [NE,R,L]

#### pages
RewriteCond %{ENV:LP2020_SUBPATH} ^.+$
#RewriteCond %{HTTP_REFERER} ^https?://redaktion(-neu)?\.braunschweig\.de/ies/infosite6/\?openObjects=
RewriteRule ^/lichtparcours2020/pages/(.+)\.json$ /lichtparcours2020/$1 [NE,R,L]

### 404
# We redirect all misses (either by the overlay above or when there is no file/dir/symlink in the publication path)
# to a small php script in the global pool in infosite that contains the following:
#
# <?php
# http_response_code(404);
# include '/var/www/braunschweig.de/apps/lichtparcours-2020-preview/public_live/404.html';
# die;
#
# which will ensure that a proper 404 status will be send. ErrorDocument 404 xxx does not work here
# as it seems to only work in global/per-virtualhost context and not per Location/Directory.
RewriteCond %{ENV:LP2020_SUBPATH} ^.+$
RewriteCond "/var/www/braunschweig.de/preview/lichtparcours2020/%{ENV:LP2020_SUBPATH}" !-f
RewriteCond "/var/www/braunschweig.de/preview/lichtparcours2020/%{ENV:LP2020_SUBPATH}" !-d
RewriteCond "/var/www/braunschweig.de/preview/lichtparcours2020/%{ENV:LP2020_SUBPATH}" !-l
RewriteRule ^.*$ /var/www/braunschweig.de/preview/lichtparcours2020/404.php [L]
