Here is a quick and easy way to provide one to one page correspondece for an english/french, english/spanish, etc
bilingual site. This little code sample is dependent on the directory stucture of the site being all in one
language. All you have to do is create a page called language_switch.php and then in your navigation include
file just link to this page


(e.g. <a href="/includes/language_switch.php).

The scipt on the page language_switch.php will take care of the rest.

Here is the code that will be in the language_switch file



<?php

	$completeNewURL = "";
	
	$referer = "$HTTP_REFERER ";
	$brokenDownReferer = "";
	
	if (stristr($referer, "/en/")){
		$brokenDownReferer = str_replace("/en/", "/fr/", $referer);
	}else{
		$brokenDownReferer = str_replace("/fr/", "/en/", $referer);
	}
	
	//These two lines of code will redirect the user to the corresponding 
	//french/english version of the page they were just on.
	
	//print("$completeNewURL");
	$URL="$brokenDownReferer";
	header ("Location: $brokenDownReferer");

?>