Hi,
I’m converting Open Source project website to caddy, and have these problems:
- example.com root should redirect to /fi/ Finnish language if it’s in Finnish, otherwise to English /en/ . I tried language plugin but it had only rewrite example. There is no PHP on that server.
Original Apache rule is:
# Automatically redirect requests on / according to the
# "Accept-Language" HTTP header, if a translation is
# available for that language.
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} (\w\w)
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^/$ /%1/ [QSA,R=302,L]
# If not, go to English.
RewriteCond %{HTTP:Accept-Language} (\w\w)
RewriteCond %{DOCUMENT_ROOT}/%1 !-d
RewriteRule ^/$ /en/ [QSA,R=302,L]
I did try this but it did not work:
locale en fi {
detect header
}
redir {
ext /
to /{>Detected-Locale}/
}
header / Vary "Accept-Language"
-
How do I get this redirect group working? In old URL it is /topics/{1}/posts/{2} and it should redirect to /posts/{2} . It could also have {2} changed to {url_escaped}.
redir 301 {
/topics/(.)/posts/(.) /posts/{2}
} -
How do I configure suburl to have html files in different directory?
Original Apache rule is:
Alias /docs /srv/http/docs
Maybe something like this?
example.com {
root /var/www/dir1
....
example.com/docs {
root /another/dir/elsewhere
}
}