ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Multi language site alternative and index.php removal with .htacces

August 18, 2008 12:10pm

Subscribe [2]
  • #1 / Aug 18, 2008 12:10pm

    glamorous_be

    19 posts

    Hello everybody,

    I configured my site with this method but in my case I’ve have to use it a little bit different.

    I changed my Javascript into:

    function switchLanguage(lang) {
            u = location.href.split('/');
            
            for(var x in u){
                if(x == 3){
                    if(lang == "en"){
                        u[2] += "/en";
                    }
                    else if(lang == "nl"){
                        u.splice(x,1);
                    }
                }
            }
    
            [removed].href = u.join('/');
        }

    A little bet explination about this:
    When the preferred language is “nl” (Dutch) the site must be parsed like this: http://www.testsite.be/testweblog/testdetail/
    When the preferred language is “en” (English) the site must be parsed like this:
    http://www.testsite.be/en/testweblog/testdetail/

    The code above works fine…

    Such as every user I also want to remove the index.php from the URL

    My .htaccess at root:

    ### MAIN DEFAULTS ###
    Options +ExecCGI -Indexes
    DirectoryIndex default.htm
    #index.html index.htm index.php
    DefaultLanguage en-US
    AddDefaultCharset UTF-8
    ServerSignature Off
    
    ### REWRITE DEFAULTS ###
    RewriteEngine On
    RewriteBase /
    
    #Handle removal of index.php from EE URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $1 !^(images|img|flash|css|js|files|lang|tinymce|themes|disclaimer|uploads|downloads|fav\.ico|robots\.txt|default.htm|sitemap\.xml) [NC]
    RewriteRule ^(.*)$ /index.php/$1 [L]

    My .htaccess in directory “en”:

    ### MAIN DEFAULTS ###
    Options +ExecCGI -Indexes
    DirectoryIndex default.htm
    #index.html index.htm index.php
    DefaultLanguage en-US
    AddDefaultCharset UTF-8
    ServerSignature Off
    
    ### REWRITE DEFAULTS ###
    RewriteEngine On
    RewriteBase /
    
    #Handle removal of index.php from EE URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $1 !^(images|img|flash|css|js|files|lang|tinymce|themes|disclaimer|uploads|downloads|fav\.ico|robots\.txt|default.htm|sitemap\.xml) [NC]
    RewriteRule ^(.*)$ /en/index.php/$1 [L]


    Now the problem:

    http://www.testsite.be/  - work fine
    http://www.testsite.be/testweblog - works fine
    http://www.testsite.be/en/index.php - works fine
    http://www.testsite.be/en/ - DOESN’T work
    http://www.testsite.be/en/site/ - DOESN’T work
    http://www.testsite.be/en/site/index.php - DOESN’T work

    Somebody an idea?!

    The .htaccess seems to work on other, not multilanguage sites.

    Thanks on beyond!

    Greetings
    Jonas

  • #2 / Aug 18, 2008 1:42pm

    Cocoaholic

    445 posts

    Hi glamorous_be.

    My knowledge of .htaccess is near zero 😉 but could it be that you need to add that “en” to the exclude list as well?

    RewriteCond $1 !^(en|images|img|flash|css|js|files|lang|tinymce|themes|disclaimer|uploads|downloads|fav\.ico|robots\.txt|default.htm|sitemap\.xml) [NC]

    I tend to use the “File and Directory Check” Method myself.

  • #3 / Aug 19, 2008 5:28am

    glamorous_be

    19 posts

    Hi Cocoaholic,

    Thanks for responding. That started me to think on something else… I’ve tried the .htaccess’es from the wiki an get a “Directory permission denied” My server didn’t find the index.php file as default page…

    Asked the man from our server to check on this, and yes, this was the problem! Sorry for the NOT-expression mistake!

    Thanks!

  • #4 / Oct 14, 2008 10:04am

    glamorous_be

    19 posts

    I’m back 😊

    Still in problems with this alternative

    Both my htaccess-files are changed like in the documentation:

    # rewrite rules
    RewriteEngine On
    
    # ditch index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /en/index.php/$1 [L]

    http://www.site.com WORKS
    http://www.site.com/fr/ WORKS

    http://www.site.com/templategroup WORKS
    http://www.site.com/fr/templategroup DOESN’T WORK => Error 404 (default language)

    http://www.site.com/index.php/templategroup WORKS
    http://www.site.com/fr/index.php/templategroup WORKS

    So I think there is something wrong with my .htaccess?

    Anyone an idea?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases