I have programmed a website on which I want to be multilingual, individual languages should be accessible through a subdomain, for example, en.example.com, de.example.com, etc.
Also, I already have a rewrite to set the “directory” as a GET variable, which changes example.com/name to example.com/index.php?page=name.
No matter what I tried, I see no way to correctly combine the two codes that I need to use with these problems. Each of them works by itself, I only need a method to combine both, so en.example.com/name will be rewritten to example.com/index.php?page=name&lang=en
What I use for directories for GET variables
RewriteRule ^/?(\w*)/?$ index.php?page=$1 [L]
What I found for subdomains for GET variables
RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{REQUEST_URI} !index\.php RewriteCond %{HTTP_HOST} ^(.+?)\.example\.com$ RewriteRule .* /index.php?lang=%1 [L]
source share