## ## AUTO NEGOTIATED LOCALE ## LanguagePriority en ForceLanguagePriority Prefer Fallback DirectoryIndex index DirectorySlash Off Options +MultiViews ## ## REWRITES ## Options +FollowSymLinks RewriteEngine On RewriteBase / ## ## remove trailing slashes (except for paths where we added the slash) ## # /en/ => /en RewriteCond %{QUERY_STRING} !end RewriteRule ^([a-z]{2})/$ /$1 [R=307,L] # /en/aaa/ => /en/aaa RewriteCond %{QUERY_STRING} !end RewriteCond %{REQUEST_URI} ^/([a-z]{2})/ RewriteCond %{REQUEST_URI} !\.html$ RewriteRule ^(.+)/$ /$1 [R=307,L] # /foo/bar.en.html/ => /foo/bar RewriteCond %{QUERY_STRING} !end RewriteCond %{REQUEST_URI} \.html/$ RewriteRule ^(.+)\.[a-z]{2}\.html/$ $1 [R=307,L] # /foo/bar/ => /foo/blah RewriteCond %{QUERY_STRING} !end RewriteRule ^(.+)/$ $1 [R=307,L] ## ## rewrite all paths with a local prefix to use ## the appropriate index.{local}.html file or ## filename.{local}.html file. ## # /en => /index.en.html RewriteCond %{QUERY_STRING} !end RewriteCond %{DOCUMENT_ROOT}/index.$1.html -f RewriteCond %{REQUEST_URI} ^/([a-z]{2})$ RewriteRule ^(.*) /index.%1.html?end [L] # /en/aaa => /aaa/index.en.html RewriteCond %{QUERY_STRING} !end RewriteCond %{DOCUMENT_ROOT}/$2/index.$1.html -f RewriteRule ^([a-z]{2})/(.*) /$2/index.$1.html?end [L] # /de/foo/bar => /foo/bar.de.html RewriteCond %{QUERY_STRING} !end RewriteCond %{DOCUMENT_ROOT}/$2.$1.html -f RewriteRule ^([a-z]{2})/(.*) /$2.$1.html?end [L] ## ## internally simulate a trailing slashes for directories in order ## to trigger DirectoryIndex and autonegotiated locale. ## # /foo/bar => /foo/bar/ RewriteCond %{QUERY_STRING} !end RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule ^(.*[^/])$ /$1/?end [PT] ## ## redirect assets that are locale prefixed ## (in order to allow relative paths) ## # e.g. /de/foo/assets/style.css => /foo/assets/style.css RewriteCond %{QUERY_STRING} !end RewriteCond %{DOCUMENT_ROOT}/$2 -f RewriteRule ^([a-z]{2})/(.*) /$2 [R=307,L]