Hi all

I try to make a multilingual site and wonder if I am heading in the right direction. My main goal is to have as few pages as possible. For now I try to make the page in English, German and Norwegian.

File system (better idea anyone?):
Root........./ (English)
.............../no/ (Norwegian)
.............../de/ (German)

As someone comes to this site they will be served the site in English and has the opportunity to select Norwegian or German language.

The URL for German language will than be www.site.com/de/ and english www.site.com/en/

But I do not want to make more than one of each file. One index.php, one gallery.php etc, and all of these files stored in root folder.

All of the text for these pages is stored in language files, en.php, no.php and de.php.

As I don't want files in www.site.com/no/ or www.site.com/de/ directory, is it possible that, when someone types www.site.com/de/index.php (an empty folder) I can use .htaccess to analyze the URL and serve the visitor www.site.com/index.php?lang=de, still showing the visitor www.site.com/de/index.php ?

I have Googled so numerous pages regarding .htaccess, but have yet to come up with a solution..

I hope I explained somehow understandable to you and that I get some response 🙂

Maybe I am way off with this method?

    I was wondering if it would make more sense to use sub-domains:

    www.example.com -> English
    de.example.com  -> German
    no.example.com  -> Norwegian
    

    They could all point to the same index file, in which you could then parse $_SERVER['SERVER_NAME'] to determine which language (template file?) to use.

      Thank you so much NogDog! The sub-domain would have worked just perfect. Googleing around for the solution to that did in fact give me the solution to original case.

      My .htaccess is now like this:
      RewriteEngine On
      RewriteRule no/(.)$ /$1 [QSA,L]
      RewriteRule en/(.
      )$ /$1 [QSA,L]
      RewriteRule de/(.*)$ /$1 [QSA,L]

      When someone tries to go to www.example.com/de/gallery.php they actually get www.example.com/gallery.php while www.example.com/de/gallery.php still shows in the browser. At top of every .php page I analyze the URL end extracts the /de/ or /en/. The .php page than loads correct language file corresponding to URL

      <?php
      $path_parts = pathinfo($_SERVER['REQUEST_URI']);
      $tempfolder = $path_parts['dirname'];
      $language = str_replace("/", "", $tempfolder);
      if (empty($language)) { $language="no";}
      include_once("language/$language.php");
      ?>

      Thank you 🙂

        I believe this has to be very friendly for the search engines to index?

          As far as I'm aware, both subdomains and directories would serve equally well with regards to SEO.

            Yes, I believe you are right Ashley. But both alternatives, subdirectory or directory is better than query strings right? I've heard that some search engines have trouble crawling sites with too long query strings? ..or maybe that applies to the past, not 2009?

              ..subdomain, not subdirectory in the post above.. 😉

                I've heard that too, from people who've heard it off of other people. I've yet to see any evidence of it though! Just look at the results you get when you type a question into your search engine of choice. Forums feature quite prominently on forums, most of which use query string URL's...

                  Write a Reply...