|
<VirtualHost *:80>
|
|
ServerName frontend-demo.openatlas.eu
|
|
DocumentRoot /var/www/frontend-demo/dist
|
|
|
|
# If you keep an .htaccess for other things, allow it; otherwise you can switch to AllowOverride None
|
|
<Directory /var/www/frontend-demo/dist>
|
|
Options FollowSymLinks
|
|
AllowOverride None
|
|
Require all granted
|
|
</Directory>
|
|
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
RewriteBase /
|
|
|
|
# =========================
|
|
# Already localized? do nothing
|
|
# =========================
|
|
RewriteCond %{REQUEST_URI} ^/(en|de)(/|$) [NC]
|
|
RewriteRule ^ - [L]
|
|
|
|
# =========================
|
|
# Bypass static & API
|
|
# =========================
|
|
RewriteCond %{REQUEST_URI} ^/(assets|dist|_nuxt|static|img|images|css|js|fonts|favicon\.ico|robots\.txt|sitemap\.xml|api)(/|$) [NC]
|
|
RewriteRule ^ - [L]
|
|
|
|
# =========================
|
|
# Localize /entity/<id>
|
|
# (note the leading slash in VirtualHost context)
|
|
# =========================
|
|
# 1) i18n cookie
|
|
RewriteCond %{REQUEST_URI} ^/entity/([0-9]+)$
|
|
RewriteCond %{HTTP:Cookie} (^|;\s*)i18n_redirected=(en|de) [NC]
|
|
RewriteRule ^/entity/([0-9]+)$ /%2/entity/%1 [R=302,L,QSA]
|
|
|
|
# 2) generic lang cookie
|
|
RewriteCond %{REQUEST_URI} ^/entity/([0-9]+)$
|
|
RewriteCond %{HTTP:Cookie} (^|;\s*)lang=(en|de) [NC]
|
|
RewriteRule ^/entity/([0-9]+)$ /%2/entity/%1 [R=302,L,QSA]
|
|
|
|
# 3) Accept-Language heuristic
|
|
RewriteCond %{REQUEST_URI} ^/entity/([0-9]+)$
|
|
RewriteCond %{HTTP:Accept-Language} ^de [NC]
|
|
RewriteRule ^/entity/([0-9]+)$ /de/entity/%1 [R=302,L,QSA]
|
|
|
|
# 4) Fallback to English
|
|
RewriteCond %{REQUEST_URI} ^/entity/([0-9]+)$
|
|
RewriteRule ^/entity/([0-9]+)$ /en/entity/%1 [R=302,L,QSA]
|
|
|
|
# =========================
|
|
# SPA fallback
|
|
# =========================
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
RewriteRule ^ /index.html [L]
|
|
</IfModule>
|
|
|
|
# Optional: gzip, caching, etc. can go here
|
|
# Enable ETag and sensible caching for assets if you like:
|
|
<LocationMatch "^/(assets|img|images|css|js|fonts)/">
|
|
ExpiresActive On
|
|
ExpiresDefault "access plus 7 days"
|
|
</LocationMatch>
|
|
</VirtualHost>
|