menardmam
menardmam

Reputation: 9986

Language neutral entry pages

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?

Upvotes: 0

Views: 318

Answers (7)

Jeremy DeGroot
Jeremy DeGroot

Reputation: 4506

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.

Upvotes: 3

Eric Petroelje
Eric Petroelje

Reputation: 60498

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';

Upvotes: 2

menardmam
menardmam

Reputation: 9986

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) ;
?>

Upvotes: 0

Gumbo
Gumbo

Reputation: 655169

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

Upvotes: 0

Nick Allen
Nick Allen

Reputation: 12210

  • 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

Upvotes: 3

Stefan Sveidqvist
Stefan Sveidqvist

Reputation: 3544

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.

Upvotes: 0

Ed James
Ed James

Reputation: 10607

Just put an argument in the php code that says :


if (lang == "")  // haven't done php in a while so the syntax is probably wrong
{
  lang = "eng";
}
In other words, if there isn't an argument on the lang variable, you can just set it to be eng automatically, and so the first page will default to English every time, unless told otherwise.

Upvotes: 1

Related Questions