There are a lot of options you can do if you use a wildcard
domain configuration. Say you have this following entry in the DNS:
*.example.com 127.0.0.1
example.com 127.0.0.1
This will redirect all the domains and sub-domains under example.com
to one single place. Such thing can be configured in Apache too.
ServerName example.com
ServerAlias *.example.com
And they all go to the same location. In PHP, you can use:
$lang = str_replace(".example.com", "", $_SERVER["HTTP_HOST"]);
And based on the variable in the $lang
you can make it. If you wanna do it for localhost
, you need to set your Apache directive this way:
<VirtualHost *:80>
ServerAdmin me@localhost.com
DocumentRoot "C:/www"
ServerName localhost
ServerAlias *.localhost
<Directory "C:/www">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>