Re: Moving to a modified URL
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Moving to a modified URL

From: eternalsword <eternalsword@gmail.com>
Date: Thu Jun 30 2005 - 19:35:25 CEST

With the method I came up with, you don't need to use cookies. If you
have already made your site, you do not need to change all of the pages
to *.php. You will need to change the links on all the pages, however,
which would be the case whether you change the file types or not. Do
something like this. If you have an index.htm or index.html page,
rename it to home.htm or home.html. Create an index.php file to put in
your www root. On the index.php have this code

$translations["en"] = ""; // default
$translations["fr"] = "fr"; // french
// $translations["language abbr"] = "language folder";
if(array_key_exists('lang',$_GET)&&array_key_exists($_GET['lang'],$translations)

// check that variable exists in url
   $lang = $_GET['lang'];
else
   $lang = $translations["en"];
ini_set("include_path", "/path/to/www/root/".$lang."/");
// change path to your path
if(array_key_exists('id',$_GET))
   $id = $_GET['id'];
if(!file_exists($id))
   $id = "error.html";
// create an error page for each lang or set $id to homepage of lang
include($id); // change ext to your file extention

use <base href="http://www.mydomain.com"> on each page. For the french
link on each page in the english section, use
<a href="index.php?id=apage.html&lang=fr">
for the english link on each page in the french section, use
<a href="index.php?id=apage">
Received on Mon Oct 17 21:00:06 2005