views:

129

answers:

7

My old web site has an index.html page … nothing strange! Everything is fine.

The new web site has an english and a french version, so the new index is index.php?lang=eng…. That makes sense.

I don’t like to make a front page that will say “english” or “french”. But that’s not good for ranking or seo.

So the question is: How do I manage to get a default index.php with request (?lang=eng) to become the front page?

+1  A: 
Ed Woodcock
Code should be more $lang=fetchLangFromQueryString();if($lang == "") $lang = "eng";, don't quite the remember the correct syntax myself either though...
Stefan Thyberg
Top guy got the syntax right.Like I said, it's been a while, we get banned from using php at Uni.
Ed Woodcock
A: 

Just make the default english and offer an option on the index page to change to french? This, of course, depends on what language most of the visitors speak, which isn't all that hard to figure out with visitor logs.

Stefan Thyberg
+2  A: 

Unless I'm misunderstanding the question, in index.php, when you check the language, put something like this:

$lang = @$_GET['lang'];
if ( empty($lang) ) $lang = 'eng';
Eric Petroelje
great i will test it.. but look good to me, thanks
marc-andre menard
Would cause an error if $_GET['lang'] is not set. Exchange the assignments and it’s fine.
Gumbo
look at my solution, mine 50% your 50% = 100% work !
marc-andre menard
I must have something funny on my server, as I've never gotten an error from accessing an invalid GET parameter (just a null value back). Still, I'll add a @ just in case
Eric Petroelje
Ah, that’s a nasty solution!
Gumbo
normally I'd say @ is evil, but in this case it's just what we want :)
Eric Petroelje
sine i dont get any error, and cannot get ANY information on the net searching for "@$_GET".. i will not add it...
marc-andre menard
FYI - Putting the "@" before a statement just means "ignore any errors that may be generated by this"
Eric Petroelje
+3  A: 
  • domain.com/en/index.php
  • domain.com/fr/index.php

Use url rewriting with regular expressions (mod_rewrite, ISAPI, whatever) to handle requests to relevant pages so

  • domain.com/en/index.php REWRITE TO domain.com/index.php?lang=en
  • domain.com/fr/index.php REWRITE TO domain.com/index.php?lang=fr

This way your pages are two seperate pages to search engines but handled via one gateway in code. I'm not a regex expert but it would be a very simple regex I would imagine

Nick Allen - Tungle139
+3  A: 

I'm not sure I understand the question. It seems to have two parts:

How to provide a default language of English:

$lang = empty($_GET['lang']) ? "eng" : $_GET['lang'];

Do you also have a problem of where to put the English/Francais links so search engines don't ding you? I wasn't aware of this problem.

It might also help to let us know if you're using a CMS, and if so which one.

(Repondez a moi en Francais si vous voulais. Je lis en francais bein meilleur que j'en ecris).

Jeremy DeGroot
A: 

I would use a neutral URL for entry, such as:

http://example.com/foo/bar

On this page I would do some language negotiation or simply ask the user for the prefered language. Then I can redirect to the language specific URL:

http://example.com/en/foo/bar
Gumbo
A: 

what do you think about that solution

<?php
    $lang = $_GET['lang'];
    if ( empty($lang) ) $lang = 'fra';
    header( 'Location: http://acecrodeo.com/new/01-acec.php?lang='.$lang) ;
?>
marc-andre menard
That's good, but it will throw either a notice or warning if $_GET['lang'] is not set. Better to assign $lang FROM $_GET only if $_GET['lang'] is not empty.
Jeremy DeGroot