GIDForums  

Go Back   GIDForums > Web Hosting Forums > Apache Web Server Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Dec-2003, 03:49
spinflip spinflip is offline
New Member
 
Join Date: Dec 2003
Posts: 3
spinflip is on a distinguished road
Unhappy

.htaccess language / rewrite problem


I am trying to setup a .htaccess file to redirect users based on their language preference but for some reason the following will not work, it just redirects to german.com every time:
Code:
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^de-at [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^de [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^de-li [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^de-lu [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^de-ch [NC] RewriteRule ^.*$ http://www.german.com [L,R] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-ar [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-bo [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-cl [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-co [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-cr [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-do [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-ec [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-sv [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-gt [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-hn [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-mx [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-ni [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-pa [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-py [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-pe [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-pr [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-us [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-uy [NC] RewriteCond %{HTTP_ACCEPT_LANGUAGE} !^es-ve [NC] RewriteRule ^.*$ http://www.spanish.com [L,R]

Could someone see if they can find an error in this file somewhere? This topic was asked on many boards but nobody posted code to show it working, so I have nothing to really go by. Any ideas would help. Thanks
  #2  
Old 15-Dec-2003, 04:16
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello spinflip,

I think your logic is wrong...

Basically your rewrite lines above work this way:

IF the HTTP_ACCEPT_LANGUAGE string does NOT start with de THEN send them to the german version of the site. Clearly this is the opposite of what you wanted!

Take off the ! (exclamation mark) in ALL your lines and the logic will be right.... I think

AND use the flag [OR] when checking for at least ONE match instead of the default [AND] in your lines now...
  #3  
Old 15-Dec-2003, 13:47
spinflip spinflip is offline
New Member
 
Join Date: Dec 2003
Posts: 3
spinflip is on a distinguished road
Thank you for your help but this still does not work:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-at [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} de [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-li [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-lu [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-ch
RewriteRule ^.*$ www.german.com [L,R]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-ar [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-bo [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-cl [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-co [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-cr [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-do [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-ec [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-sv [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-gt [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-hn [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-mx [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-ni [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-pa [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-py [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-pe [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-pr [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-us [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-uy [OR]
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es-ve
RewriteRule ^.*$ www.spanish.com [L,R]
  #4  
Old 15-Dec-2003, 14:01
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Sample rewrite rules for your situation...


Try something like this for starters, then if it works, you can experiment further:

Code:
Options +FollowSymLinks RewriteEngine On # GERMAN RewriteCond %{HTTP_ACCEPT_LANGUAGE} ^de [NC] RewriteRule ^.*$ http://www.german.com [L,R] # SPANISH RewriteCond %{HTTP_ACCEPT_LANGUAGE} ^es [NC] RewriteRule ^.*$ http://www.spanish.com [L,R]
  #5  
Old 15-Dec-2003, 14:04
spinflip spinflip is offline
New Member
 
Join Date: Dec 2003
Posts: 3
spinflip is on a distinguished road
I don't know why but it does not work. I am setting my language prefs in my browser to test, but I dont think that is the problem.
  #6  
Old 15-Dec-2003, 14:14
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
You can quickly test your HTTP_ACCEPT_LANGUAGE by viewing a phpinfo file and looking for the value under Apache Environment.

If it's what you expected, then post the value you found since I am not too well versed with this particular variable and what it may contain.
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess on Windows2k, and the trailing slash Pedster2k Apache Web Server Forum 6 24-Jan-2004 17:32
unwanted scrollbar problem kelly001 Web Design Forum 3 24-Oct-2003 10:44
problem with creating class mohammed C++ Forum 1 11-Oct-2003 09:04
Problem with .htaccess Zergus Apache Web Server Forum 7 29-Jul-2003 11:01
How I sorted my website compression problem jrobbio MySQL / PHP Forum 0 05-Mar-2003 20:41

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:18.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.