php - Apache2 SetEnvIfNoCase using Request_URI -
i'm trying set locale environment variables in vhost on apache server, requested path define locale used. requirement use more "consumer friendly" locale code, rather iso format - need map supported iso format in framework.
for example: http://site.com/uk/path/to/page.html
set environment variable of req_locale=en_gb
and want default english if unexpected locale found.
what i'm trying use @ moment apache setenvifnocase
directive in manner:
setenvifnocase request_uri ^/eu req_locale=en_us setenvifnocase request_uri ^/es req_locale=es_es setenvifnocase request_uri ^/de req_locale=de_de setenvifnocase request_uri ^/fr req_locale=fr_fr setenvifnocase request_uri ^/it req_locale=it_it setenvifnocase request_uri ^/uk req_locale=en_gb setenvif req_locale ^$ req_locale=en_us
for reason last directive being called. if remove ^/
regexes de
1 always called.
so.. i'm @ bit of loss :)
can help? (nb: i've tried using request_uri
request_uri
- no change in result)
edit think following rewrite rule causing issue:
rewriterule .* index.php [l]
looking @ rewritelog - seems causing redirect , environment variable isn't being carried across. so...
use this:
# initialize env var en_us setenvifnocase request_uri "^" req_locale=en_us # set conditionally setenvifnocase request_uri "^/eu" req_locale=en_us setenvifnocase request_uri "^/es" req_locale=es_es setenvifnocase request_uri "^/de" req_locale=de_de setenvifnocase request_uri "^/fr" req_locale=fr_fr setenvifnocase request_uri "^/it" req_locale=it_it setenvifnocase request_uri "^/uk" req_locale=en_gb
edit: can chanege rewrite rule this:
rewritecond %{query_string} ^$ rewriterule ^ index.php?lc=%{env:req_locale} [l,qsa]
Comments
Post a Comment