-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
47 lines (38 loc) · 1.61 KB
/
.htaccess
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
layout: null
---
ErrorDocument 500 /500.html
ErrorDocument 404 /404.html
# index.xml for RSS
DirectoryIndex index.html index.xml
RewriteEngine on
# Trailing slash.
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule (.*/)index\.html$ /$1 [R=301,L]
# Default language.
SetEnvIf Remote_Addr . LANG=en
# If accepting Danish, use Danish as default.
SetEnvIf Accept-Language da LANG=da
# If cookie is set it overrides the default.
SetEnvIf Cookie language=(da|en) LANG=$1
# Keep last language visited.
# Final override of language variable.
RewriteRule ^(da|en)/.*$ - [E=LANG:$1,CO=language:$1:bubula2.com:525600]
# Root redirects to latest comic.
RewriteRule ^$ /%{ENV:LANG}/
RewriteRule ^da/$ /da/{{ site.data.tr.comics["da"] }}/{{ site.posts.first.slug }}/ [L]
RewriteRule ^en/$ /en/{{ site.data.tr.comics["en"] }}/{{ site.posts.first.slug }}/ [L]
# Permalink (/<id>/) shows current language.
RewriteCond %{ENV:LANG} da
RewriteRule ^[0-9]+/$ /da/{{ site.data.tr.comics["da"] }}/$0 [L]
RewriteCond %{ENV:LANG} en
RewriteRule ^[0-9]+/$ /en/{{ site.data.tr.comics["en"] }}/$0 [L]
# Redirect easier url. We cannot do it via the following permalink rules
# because we want the code to be 301, not 307. The chosen language url
# is constant while permalink is a link to the comic independent of language.
RewriteRule ^da/([0-9]+)/$ /da/{{ site.data.tr.comics["da"] }}/$1/ [R=301,L]
RewriteRule ^en/([0-9]+)/$ /en/{{ site.data.tr.comics["en"] }}/$1/ [R=301,L]
# Redirect to language based on language of the "comics" part.
RewriteRule ^striber/.*$ /da/$0 [R=301,L]
RewriteRule ^comics/.*$ /en/$0 [R=301,L]