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.

Member Login Problem on Multi-Language Site

April 04, 2012 6:14am

Subscribe [2]
  • #1 / Apr 04, 2012 6:14am

    daniel.kaminski

    4 posts

    Hello,

    the multi-language alternative, where a sub-directory is used for each language seems to break my member log-in, that is, if I’m not missing something.

    The starting point
    I have two language directories, say en/ and de/ each with their respective index.php and .htaccess files. The htaccess files also eliminates the index.php in the uri’s. The multi-language set-up itself works like a treat, with a language switch and a small custom plug-in visitors can switch languages at any point and also third party add-on navee was a nice fit for fulfilling the multi-language requirement. So far so good.

    The problem
    Now when I implement a log-in form it only seems to actually work from within root directory. When I’m trying to log in from /en or de/ I’m not authenticated and i’m redirected to http://mydomain.com/mydomain.com/de .

    Does anybody have an idea where where my problem could be?

    Thanks,
    Daniel

    Reference index and .htaccess alterations as used
    E.g. the /en/index.php got the following two lines added:

    $assign_to_config['global_vars']['language'] = "en";
    $assign_to_config['site_url'] = getenv('HTTP_HOST') . "/en";

    and the system reference to the system path was altered

    $system_path = '../system';

    and the /en/.htaccess looks as follows:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]
    
    # Enforce NO www
    RewriteCond %{HTTP_HOST} ^www [NC]
    RewriteRule ^(.*)$ <a href="http://domain.tld/en/$1">http://domain.tld/en/$1</a> [L,R=301]
    
    # Removes index.php
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /en/index.php/$1 [L]
    
    # If 404s, "No Input File" or every URL returns the same thing
    # make it /index.php?/$1 above (add the question mark)
    </IfModule>
  • #2 / Apr 04, 2012 2:37pm

    daniel.kaminski

    4 posts

    Problem solved. Just in case somebody else encounters the same problem: the reason was the definition of the site_url config variable:

    I had the following in the /de/index.php file:

    $assign_to_config['site_url'] = getenv('HTTP_HOST') . "/de";

    The login form was rendered with an action attribute of “mydomain.com/de” which obviously is not correct.

    So simple fix is to add the http protocol in front:

    $assign_to_config['site_url'] = "http://" . getenv('HTTP_HOST') . "/de";
  • #3 / Apr 05, 2012 10:31am

    Shane Eckert

    7174 posts

    Hey Daniel,

    I am glad to see that you were able to get this working. Nice bit of work!

    If you do need anything else in the future, please let us know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases