Reputation: 17205
I am trying to match the words 'blogs' and 'news' in the following url
according to the detected language via htaccess
.
the url:
http://localhost/es/noticias
the language detection (working):
RewriteCond %{HTTP_HOST} ^(es)\. [OR]
RewriteCond %{REQUEST_URI} .*/(es)/.*
RewriteRule ^(.*) - [E=LANG:%1,E=NEWS:noticias,E=BLOGS:blogs]
the rule (not matching ENV:BLOGS nor ENV:NEWS)
RewriteRule ^([^\/]+/)?(%{ENV:BLOGS}|%{ENV:NEWS}) index.php?vd=%{ENV:LANG}/$1&m=$2 [NC,QSA,L]
How to match Env Variables in Rewrite Rule
?
EDIT 1 - the extended language translation
RewriteCond %{HTTP_HOST} ^(es)\. [OR]
RewriteCond %{REQUEST_URI} .*/(es)/.*
RewriteRule ^(.*) - [E=LANG:%1,E=NEWS:noticias,E=BLOGS:blogs]
RewriteCond %{HTTP_HOST} ^(en)\. [OR]
RewriteCond %{REQUEST_URI} .*/(en)/.*
RewriteRule ^(.*) - [E=LANG:%1,E=NEWS:news,E=BLOGS:blogs]
RewriteCond %{HTTP_HOST} ^(fr)\. [OR]
RewriteCond %{REQUEST_URI} .*/(fr)/.*
RewriteRule ^(.*) - [E=LANG:%1,E=NEWS:nouvelles,E=BLOGS:blogosphere]
Upvotes: 1
Views: 940
Reputation: 785126
Rather than RewriteRule
you need to use RewriteCond
for matching env variables. See this code snippet:
RewriteCond %{ENV:BLOGS} ^blogs$ [OR]
RewriteCond %{ENV:NEWS} ^noticias$
# some RewriteRule here
RewriteRule ^ - [L]
RewriteRule
on the other hand is used for matching request URI only.
Upvotes: 2