Forum Moderators: phranque
I want to do the following:
en.example.com
en.example.com/forum/
en.example.com/login/
index.php?language=en
index.php?language=en&page=forum
index.php?language=en&page=login
The same for each language. The index page uses the language sub domain, but I also want to use the directory.
Code:
RewriteCond %{HTTP_HOST} ^(de¦en¦fr¦ger¦it¦es)\.example\.com$
RewriteRule ^$ /index.php?language=%1
RewriteRule ^forum/ /index.php?page=forum&language=%1
RewriteRule ^login/ /index.php?page=login&language=%1
it either does the language or the page how can I make it return both page and language
Help would be greatly appreciated.
Or can two rewriterules be used? the first setting the language
RewriteCond %{HTTP_HOST} ^(de¦en¦fr¦ger¦it¦es)\.example\.com$
RewriteRule ^$ /index.php?language=%1
and another for getting the directory?
RewriteCond %{HTTP_HOST} ^(de¦en¦fr¦ger¦it¦es)\.example\.com$ [NC]
RewriteRule ^/($¦index.php)¦(forum¦login)/(index.php)? /index.php?page=$2&language=%1 [L]
(seems a little ugly; I'd be interesting in seeing if there's a better solution to this)
The downside to the above, is that it doesn't fully deal with mixed/upper-case Host: headers correctly. If you can handle that at the application, that's fine. If not, you'll need to augment to:
RewriteMap tolower int:tolower
RewriteCond %{HTTP_HOST} ^(de¦en¦fr¦ger¦it¦es)\.example\.com$ [NC]
RewriteRule ^/($¦index.php)¦(forum¦login)/(index.php)? /index.php?page=$2&language=${tolower:%1} [L]
RewriteCond %{HTTP_HOST} ^(de¦en¦fr¦ger¦it¦es)\.example\.com$ [NC]
to apply to all the rules.
The problem with the Rewriterule is it only takes the language and page paramaters.
If I wanted another rule which took more paramaters, say an article id, page and language, and passed that to the index page the above rules wouldnt work.
But the article will only apply to one rule so I cant pass it everytime to the above rule.