I wish to create a multi-lingual website that defaults to British like example.com with subdomains like fr.example.com, p.example.com, it.example.com ...
now, when the user chooses fr.example.com, the site's language is going to be French.
when the subdomain is fr, PHP includes lang_fr.php, if p, PHP includes lang_p.php, but when there's no subdomain, PHP must range from the default file lang_en.php
The website should have just one source code, content and elegance, it has to make use of the same assets that'll be within the cause of example.com.
So using Apache to rewrite the URL from fr.example.com to example.com/index.php?lang=fr and example.com/ to example.com/index.php?lang=en
You don't have to rewrite anything. Just check $_SERVER['SERVER_NAME'].
function get_language() examined $default_language = 'en' $language = array_change(explode('.', $_SERVER['SERVER_NAME'] )) if ( str_len( $language ) > 2 ) return $language