I lately discovered the energy from the mod_rewrite module and that i take some assist with it.

Say I've got a website that has two domains mapping towards the same host...


And I must set a GET var with respect to the the HTTP_HOST (i.e. .com OR .internet ?) ...


Nevertheless the caveat is.. I curently have 3 RewriteRules...

RewriteRule ^(about|contact)/?$ /index.php?page=$1 [NC]

And when I would stick to the example over here (bottom of RewriteCond) I would need to copy the three RewriteRules for every HTTP_HOST (i.e. .com OR .internet) and add the GET var statically like &lang=en OR &lang=es and also the finish of every rule...

Can there be some method of doing this instantly without needing to copy the three rules once again which only differ just by one get var in the finish?

PS. I understand you can do this with the scripting language, but I'm wondering if you can do this through mod_rewrite, and just how.


Try putting something similar to this before all of your other rules:

RewriteCond %{HTTP_HOST} .com$
RewriteRule ^(.*)$ $1?lang=en [QSA]
RewriteCond %{HTTP_HOST} .net$
RewriteRule ^(.*)$ $1?lang=es [QSA]

Although you may be best utilizing an atmosphere variable to specify the word what, while using SetEnv directive having a different language in every virtual host.

And maybe even even better, consider mod_negotiation, which consists of some standard abilities for coping with languages.