Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Redirecting from landing page of a php+mysql multilingual site?
Old 04-09-2009, 11:37 AM Redirecting from landing page of a php+mysql multilingual site?
micro^earthling's Avatar
Novice Talker

Posts: 7
Name: Sourjya Sankar Sen
Trades: 0
Hey guys! I'm designing this multi-lingual site with php + mysql. I'm using a 2 letter language code following the domain name to identify the language the content is delivered in. For example,
www.domain.com/en - English
www.domain.com/th - Thai and so on...

All URLs (am utilizing mod_rewrite) take the general form,
http://www.domain.com/2_char_languag...page_slug.html

Here's my problem scenario:

When person A visits the site by keying in www.domain.com/lang_code, I can directly serve the pages in the desired language.

If person A keys in just www.domain.com (without any language code), I redirect to the english page by default - but I'm in a dilemma as to what redirection header to serve for this URL. I had read about a '300 Multiple Choice" header and that's what I have implemented experimentally.

Here's the code:

PHP Code:
header'HTTP/1.1 300 Multiple Choices' );
header'Location: ' DOMAIN '/en' ); 
Is this the correct way to do it?

I had thought of using a 301 earlier on - but that didn't strike quite right.

Has anyone worked on such a case and can throw some light on this?

Thanks,
m^e
__________________
PeoPLe aRe cRazY anD tiMeS aRe sTRaNGe, i'M LoCKeD iN tiGhT, i'M OuT oF raNGe, i uSeD t0 caRe BuT - thiNGs haVe ChaNGeD.

Please login or register to view this content. Registration is FREE
... Technology News & Reviews
micro^earthling is offline
Reply With Quote
View Public Profile Visit micro^earthling's homepage!
 
 
Register now for full access!
Old 04-09-2009, 02:02 PM Re: Redirecting from landing page of a php+mysql multilingual site?
Novice Talker

Posts: 5
Trades: 0
The way I did it was use cookies to see if the user set the language, if its no set, use the default language. If set just include language files which had the definitions of words.
Sarvar is offline
Reply With Quote
View Public Profile
 
Old 04-09-2009, 08:59 PM Re: Redirecting from landing page of a php+mysql multilingual site?
micro^earthling's Avatar
Novice Talker

Posts: 7
Name: Sourjya Sankar Sen
Trades: 0
@Sarvar: Yup! That's exactly the model I'm following behind the scenes.. but the issue I have isn't about storing or redirection according to a particular user preference. It's more about proper redirection while traversing xxx.com --> xxx.com/lang_code.

It's not a 301 for sure, coz that would imply xxx.com = xxx.com/en (in my case). to a search engine crawler... which is not quite correct, if you know what I mean!

Awaiting more feedback on this

Thanks,
m^e
__________________
PeoPLe aRe cRazY anD tiMeS aRe sTRaNGe, i'M LoCKeD iN tiGhT, i'M OuT oF raNGe, i uSeD t0 caRe BuT - thiNGs haVe ChaNGeD.

Please login or register to view this content. Registration is FREE
... Technology News & Reviews
micro^earthling is offline
Reply With Quote
View Public Profile Visit micro^earthling's homepage!
 
Old 04-09-2009, 09:14 PM Re: Redirecting from landing page of a php+mysql multilingual site?
Novice Talker

Posts: 5
Trades: 0
I have no idea why you are using 301 headers. Can't you just redirect them with header()?

This is how I did it. Hope it will help:
Person clicks on language => header("Location: switch_lang.php?lang=en");
Then switch_lang.php stores a session with lang=> header("Location: ".$_SERVER['HTTP_REFERER']); which will go back to wherever the user clicked the link from.

Every page will include a function to get session lang and include appropriate language file.

So when I click on the language, the page just refreshes once; changing the language.
Sarvar is offline
Reply With Quote
View Public Profile
 
Old 04-10-2009, 11:18 AM Re: Redirecting from landing page of a php+mysql multilingual site?
reli4nt's Avatar
Extreme Talker

Posts: 168
Location: New York
Trades: 0
From what I understand the 300 code is correct for your situation. It communicates to search engines and others that the page the user is being redirected to is not the only choice and should therefore not be mistaken for "httP://yoursite.com/"

The 301 essentially says that the two are synonymous which isn't true here.

Sarvar's method is a bit more maintainable especially when you have numerous languages but the most versatile would be to store your various translations in the db and not hard coded files.
__________________

Please login or register to view this content. Registration is FREE

Designing the world we live in.
Defining the terms we live by.
reli4nt is offline
Reply With Quote
View Public Profile Visit reli4nt's homepage!
 
Reply     « Reply to Redirecting from landing page of a php+mysql multilingual site?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21615 seconds with 12 queries