When visiting the website www.example.com/ the visitor should be redirected to the correct language version, e.g. www.example.com/en for english and www.example.com/es for spanish.
My current implementation only works when visiting www.example.com/index.var and redirects to www.example.com/index.en. Now I want to rewrite this to www.example.com/en/
My implementation is based on https://httpd.apache.org/docs/2.4/content-negotiation.html.
.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /
AddHandler type-map .var
LanguagePriority en es de
ForceLanguagePriority Fallback
index.var
URI: index; vary="language"
URI: index.en.html
Content-type: text/html
Content-language: en
URI: index.es.html
Content-type: text/html;charset=utf-8
Content-language: es
URI: index.de.html
Content-type: text/html;charset=utf-8
Content-language: de
Important: MultiViews are disabled
Looking forward to your great solutions.
to explain this a little more in detail...
Here's an example of my file structure:
File should be rewritten or redirected to - index.var --> / - index.en.html --> /en/ - index.es.html --> /es/ - about.var --> /about - about.en.html --> /en/about - about.es.html --> /es/about - images/img_1.jpg --> /images/img_1.jpg - images/logo.var --> /images/logo.png (not a file) - images/logo.en.png --> /en/images/logo.png - images/logo.es.png --> /es/images/logo.png
Rewriting of images and other resources is optional. It's only important to get rewriting of html files right.
The Apache Documentation is a working example of this (using content negotiation).
about.var
get redirected whileimages/logo.var
does not? – Stephen Ostermiller♦ Feb 23 '18 at 11:18