List Info

Thread: mod_rewrite problem




mod_rewrite problem
user name
2006-02-09 08:02:50
Thank you, Mike.

"[L]" means "last rule", so if this set
of Condition and Rule apply,
nothing below this will be executed: if language
"de" is given, the
first Rule will be executed and nothing else; if no
"de" we search for
"en"; if "en", we execute the second
Rule and then stop; if no "en" the
last Rule will be executed - it has no Condition and will be
executed
under all circumstances (exept when one of the other Rules
gets
executed and "[L]" makes the script stop.

[L] is like exit(); in PHP.
RewriteCond is like if() in PHP.
No Cond is like else {} in PHP.

So all of the above means (sort of):

if (deutsch) deliver deutsch then stop; elseif (english)
deliver
english then stop; else deliver (norwegian);

If I put the last, the ".../no/"-Rule first, only
this one will be
executed.

By the way, I have found  a solution  that works. I needed
to ask for
the HTTP-header, because RewriteCond does not accept
HTTP_ACCEPT_LANGUAGE. This  works:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP:Accept-Language} ^.*de.*$ [NC]
RewriteRule ^(index.php)?$ http://www.domain.com/de/ [L,R=301]

RewriteCond %{HTTP:Accept-Language} ^.*en.*$ [NC]
RewriteRule ^(index.php)?$ http://www.domain.com/en/ [L,R=301]

RewriteRule ^(index.php)?$ http://www.domain.com/no/ [L,R=301]

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )