Nov 8, 2009

Redirecting From Landing Page Of A Php+mysql Multilingual Site?

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Redirecting From Landing Page Of A Php+mysql Multilingual Site?

miCRoSCoPiC^eaRthLinG
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,
www.domain.com/2_char_language_code/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:

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

P.S. And don't gawk at me biggrin.gif Been keeping ultra-busy doin' some hardcore php!

 

 

 


Comment/Reply (w/o sign-up)

mastercomputers
Hey m^e,

I think you're looking at this the wrong way, people should not have to key in the information for what language they want.

One way is we could use content negotiation based on users preferences, which is based entirely on the server communicating with the client (web browser) and selecting the appropriate content, based on their preference. There can be some changes to how this originally works with Apache, in which we can use server-side languages to intercept and generate the appropriate content.

By the way, Header 300 would be correct if you used content negotiation like above, otherwise, you're not really giving the user/user-agent a choice.


Cheers,


MC

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
Aha MC biggrin.gif Long time....

QUOTE
One way is we could use content negotiation based on users preferences, which is based entirely on the server communicating with the client (web browser) and selecting the appropriate content, based on their preference. There can be some changes to how this originally works with Apache, in which we can use server-side languages to intercept and generate the appropriate content.


Yup! For content negotiation I'm relying mostly on cookies and sessions... if either are found, the site redirs to a particular lang version automatically... That part is taken care of.

However, it's the redirection issue - for people who arrive at the primary domain - that's got me a little baffled..

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!

Studying the different header types - 300 seems to be the only logical choice, but I didn't manage to find any hands-on (code) examples of implementation. So am kind of unsure if I'm doing it right!

Good to see you around smile.gif

Cheers,
m^e

 

 

 


Comment/Reply (w/o sign-up)

yordan
How does google do this ? You type www.google.com, and you reach www.google.fr or www.google.ca or www.google.sp

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
Google most likely does it using the combination of cookies and a Geo-IP service.

First when you type Google.com and your browser doesn't contain any cookies set by them, the redirection occurs according to your IP (ISP) location and the cookie for the same is set in your browser.

If you set the google domain for another language as your preferred one, the cookie is altered accordingly.

Next visit onwards you are auto-redirected based on the cookie.

I'm following a similar model here - and you've brought up a good point. Maybe I should try analyzing the headers and see how they're performing the redirection.

Thanks,
m^e

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords :

  1. Should This Great Site Offer Imagemagick ?
    May be the admin of this site think over it. (3)
  2. Dynamic Site Design - Where Do I Start ?
    (7)
    I am new to php. I have some programing background in html, javascript, and c++ but have never done
    anything in php Can someone reccomend some good sites or books etc that can help someone who is
    completely new? My ultimate goal is to make a game like/similar to ponyisland.net....
  3. Need Help Is Adding A PHP Based News Module To My Site
    (2)
    Hey guys i need a simple help i'm builing a homesite and i have a little spot for news. Well i
    just place there the Topics and add a link to another page "news.php". Well its obvious that i dont
    want to build a file for each news that i have so i know that exists a way to work with SQL & PHP. I
    will show want i'm doing CODE        require ('mysql.php');       
    $query="SELECT * FROM News ORDER BY `data` ASC LIMIT 0,5 ";        $result=mysql_query($query);
               $num=mysql_num_rows($result); mysql_close(); echo " Outras Other News "; $i=....
  4. Multilingual Site: Send The User To Page Of Choice
    (6)
    If you have one site in diferent laanguages, this simple script can redirect the user to the correct
    page acording to his/her language: CODE // Enslish EUA elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-us"){ header("Location: index_eng.html"); } // Inglês UK elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-gb"){ header("Location: ingles_enuk.html"); } // Portuguese if ($HTTP_ACCEPT_LANGUAGE ==
    "pt-br"){ header("Location: index_ptbr.html"); } //German elseif ($HTTP_ACCEPT_LANGUAGE ==
    "de-de"){ header("Location: index_ger.html"); } // Swedish elseif ($HTTP_ACCEPT....
  5. Using Bitflags To Restrict Site/page Permissions
    (1)
    My professor is designing a website that uses bit-flag checking to allow access to certain pages.
    You login, validate login, and store their allowed bit flag into a session variable. Then you
    compare to see if they have access or not. It's fairly new to me, but it's apparently very
    common with linux users. Sounds interesting to me, just wondering if any one has used this, or is
    it a little too much for simple pages. His site however is going to be more of "software" for
    several users. Is it very secure and does it work well?....
  6. How To Use Cookie In Your Web Site ?
    this semple code to use and get cookie (1)
    what is the cookie ? the cookis it is some info sent and save in user computer whare i can use the
    cookies? becouse the cookies it like the header you can not send it after any output wes sent so
    you must send the cookies before any output like as ,echo and any other code i well make an E.X.
    to use the cookies you must have 2 file index.php update.php ---------- in the index.php add this
    code CODE    // This section must go at the top of the page that will display    // the
    users favorites.  These are the 'default' URLs that the user    // will se....
  7. Do You Want A Mail Form In Your Site
    (2)
    Notice from m^e: Repeat post. Credits reduced by 5 days. Learn to USE
    THE SEARCH BUTTON before you make such posts. did you want to have in your web site mail form
    that allow the user to send mails to anther mail from his mail e.g. the compose in yahoo CODE
    from to cc bcc subject
    function param($Name)         {         global
    $HTTP_POST_VARS;         if(isset($HTTP_POST_VARS ))            return($H....
  8. Own Links On Site
    (6)
    I'm thinking of having some kind of system so the users can register and then put up their
    links. Everything should be saved in some kind of database. Anyone now any tutorial or guide or
    something like that of how to do that?....
  9. PHP Based Site Access Authentication - Help
    How to block parts of your web-site ?? (4)
    How can i program my web page using php that when the value of the login box is equal to some string
    then go to my success.html otherwise on my fail.html????help me guys!
    ------------------------------------ It would help the readers far better to understand what your
    problem is - if you state the nature of it in short in your topic title, instead of just "Php help".
    It'll also get you a lot more responses. Am changing your topic title to give you an example.
    All the best /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> m^e....
  10. Site Counters - Help Needed
    (13)
    I want a good Site counter(to keep track of visitors) for my site..... can nebody temme.....
    where will i get free stuff on this... (dont ask me to google..and try out..i am doing that..just in
    case u know someplace) OR Can how do i design my own (which seems quite....difficult for me) Plz
    help!! Satya....
  11. Php Script To Download File From Another Site
    (11)
    hi i need a php or java script code for downloading files from other sites to my site for example:
    http://download.com/file.zip to http://mysite.com/file.zip thanks....
  12. How Do U Make Members Only Web-site
    (7)
    how do u make it that only a member of that site can view that page?....

    1. Looking for Redirecting, From, Landing, Page, Of, A, Php+mysql, Multilingual, Site?

See Also,

*SIMILAR VIDEOS*
Searching Video's for Redirecting, From, Landing, Page, Of, A, Php+mysql, Multilingual, Site?
advertisement



Redirecting From Landing Page Of A Php+mysql Multilingual Site?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com