-5

I'm using: http://localhost/en/index.php to indetify the current sites language.

But, I'm searching a way to do like this : http://en.localhost/index.php

Maybe some webserver configurations or frameworks would help.

After all my research I wasn't able to find a solution. Thank you and have a nice day.

Vladimir
  • 5
  • 4
  • It's depend on you how to use create sub domain or add extra parameter in url – Keval Rathi Sep 04 '15 at 11:33
  • This is too broad to answer, but you have to set DNS Wildcard on your domain first, and then use URL Rewriting to achieve that. – Ahmad Sep 04 '15 at 11:37
  • Sorry, I got no idea from where to start with. That's why it's broad, If I had some tips I wasn't asking here and researching instead. I never asked to write a tutorial for me, just some tip that could support my research. Thank you. – Vladimir Sep 04 '15 at 11:41
  • @Heru-Luin y it should be, thank you ! I got everything I needed. – Vladimir Sep 04 '15 at 11:42
  • @Vladimir We are not here to help you with your research or "get you started". – Epodax Sep 04 '15 at 11:46
  • @Epodax So why are you here ? – Vladimir Sep 05 '15 at 10:10
  • @Vladimir To help people who do their research and have actual coding problems. – Epodax Sep 05 '15 at 16:28

1 Answers1

2

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>
Praveen Kumar Purushothaman
  • 154,660
  • 22
  • 177
  • 226