Multi language site alternative and index.php removal with .htacces
Posted: 18 August 2008 09:10 AM   [ Ignore ]  
Summer Student
Total Posts:  26
Joined  04-14-2008

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

Profile
 
 
Posted: 18 August 2008 10:42 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi glamorous_be.

My knowledge of .htaccess is near zero wink 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.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 19 August 2008 02:28 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  26
Joined  04-14-2008

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!

Profile
 
 
Posted: 14 October 2008 07:04 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  26
Joined  04-14-2008

I’m back smile

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?

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64937 Total Logged-in Users: 56
Total Topics: 81904 Total Anonymous Users: 25
Total Replies: 440290 Total Guests: 299
Total Posts: 522194    
Members ( View Memberlist )