Skip to content

Commit

Permalink
Apache: redirect homepage based on accept-language
Browse files Browse the repository at this point in the history
  • Loading branch information
Noki authored and noxilixon committed Jan 23, 2024
1 parent dbe1f9d commit 8844932
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions apache/website.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
DocumentRoot /var/www/404

RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=302,L]
RewriteCond %{REQUEST_URI} !^/.well-known/
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=301,L]
RewriteRule ^/index_en https://berlin.freifunk.net/en/ [R=301,L]
RewriteRule ^/$ https://berlin.freifunk.net/en/ [R=302,L]
RewriteRule ^/index_en/$ https://berlin.freifunk.net/en/ [R=301,L]
RewriteRule ^/network https://berlin.freifunk.net/de/map/ [R=301,L]
RewriteRule ^/contact/$ https://berlin.freifunk.net/de/contact/ [R=301,L]
RewriteRule ^/contact_en/$ https://berlin.freifunk.net/en/contact/ [R=301,L]
Expand All @@ -18,6 +20,10 @@
RewriteRule ^/wiki/$ https://berlin.freifunk.net/de/wiki/ [R=301,L]
RewriteRule ^/meshwiki$ https://berlin.freifunk.net/de/wiki/ [R=301,L]
RewriteRule .* https://berlin.freifunk.net%{REQUEST_URI} [R=301,L]

<LocationMatch "^/$">
Header always merge Vary "Accept-Language"
</LocationMatch>
</VirtualHost>

<VirtualHost *:443>
Expand All @@ -29,8 +35,10 @@
SSLCertificateKeyFile /etc/letsencrypt/live/www.berlin.freifunk.net/privkey.pem

RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=302,L]
RewriteCond %{REQUEST_URI} !^/.well-known/
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=301,L]
RewriteRule ^/$ https://berlin.freifunk.net/en/ [R=302,L]
RewriteRule ^/index_en https://berlin.freifunk.net/en/ [R=301,L]
RewriteRule ^/network https://berlin.freifunk.net/de/map/ [R=301,L]
RewriteRule ^/contact/$ https://berlin.freifunk.net/de/contact/ [R=301,L]
Expand All @@ -43,15 +51,25 @@
RewriteRule ^/meshwiki$ https://berlin.freifunk.net/de/wiki/ [R=301,L]
RewriteRule ^/impressum/$ https://berlin.freifunk.net/de/impressum/ [R=301,L]

<LocationMatch "^/$">
Header always merge Vary "Accept-Language"
</LocationMatch>
</VirtualHost>

<VirtualHost *:80>
ServerName www.berlin.freifunk.net
ServerAdmin "[email protected]"

RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=302,L]
RewriteCond %{REQUEST_URI} !^/.well-known/
RewriteRule .* https://berlin.freifunk.net/de/ [R=301,L]
RewriteRule ^/$ https://berlin.freifunk.net/en/ [R=302,L]
RewriteRule .* https://berlin.freifunk.net/en/ [R=301,L]

<LocationMatch "^/$">
Header always merge Vary "Accept-Language"
</LocationMatch>
</VirtualHost>

<VirtualHost *:443>
Expand All @@ -65,8 +83,10 @@
DocumentRoot /var/www/berlin.freifunk.net/www

RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=302,L]
RewriteCond %{REQUEST_URI} !^/.well-known/
RewriteRule ^/$ https://berlin.freifunk.net/de/ [R=301,L]
RewriteRule ^/$ https://berlin.freifunk.net/en/ [R=302,L]
RewriteRule ^/index_en https://berlin.freifunk.net/en/ [R=301,L]
RewriteRule ^/network https://berlin.freifunk.net/de/map/ [R=301,L]
RewriteRule ^/contact/$ https://berlin.freifunk.net/de/contact/ [R=301,L]
Expand All @@ -78,6 +98,10 @@
RewriteRule ^/wiki/$ https://berlin.freifunk.net/de/wiki/ [R=301,L]
RewriteRule ^/meshwiki$ https://berlin.freifunk.net/de/wiki/ [R=301,L]

<LocationMatch "^/$">
Header always merge Vary "Accept-Language"
</LocationMatch>

Header set Content-Security-Policy "script-src berlin.freifunk.net"
Header set Strict-Transport-Security "max-age=63072000; includeSubDomains"

Expand Down

0 comments on commit 8844932

Please sign in to comment.