I have a website in 2 languages. I'm inserting the text for each language through php constants and I define the user language through a cookie (lang=es
or lang=en
).
Now the base url in each language is www.webname.com/
but i want to rewrite it depending on the language. If the cookie is set to es
the url must be www.webname.com/es/
and if it's in en
must be www.webname.com/en/
.
I'm looking in some manuals and tutorials but i'm really very bad with regular expressions.
EDIT: I'm working on something like that in my .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_COOKIE} lang=en;? [NC]
If I put a redirection like:
RewriteRule ^ http://www.google.com [NC,L]
after it, it works but i don't know how to do the same with a rewrite.