473,246 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Moving to a modified URL

I would like to create a link on a web page that will call a script and jump
to an URL similar but slightly different than the current one. I am doing
this to allow people to switch languages. For example, no matter where the
user is on my web site, if he clicks on the FRENCH button at the top, he
will be moved from:




On this French version of the web page, if he clicks on the ENGLISH button,
he will be moved back to the:


Since we have more than 60 pages, we don't want to create 120 links on each
page. We would prefer to have two scripts, one that will insert a /fr after
the domain name (to move to the French site), and another one that will
remove this /fr in order to move to the English version of this page.

Is this something that can be done with PHP?

Normand P.
Jul 17 '05 #1
4 1622
Since you seem to have currently all your pages in html, you would
probably have to run through some trouble. First, you'd need to rename
all your files to have a .php extension. Then you should write a PHP
script that creates the French, English, Spanish etc buttons with the
modified URL. And then place a call to said script on top of each page.

You may also be interested in using frames. They are ugly as sin, but
look like a better solution for your particular matter, since you'd
probably only need one php page to show in the top frame, and it would
control the html content of the bottom frame.

Jul 17 '05 #2
you could do it with a 404 error handler (u need apache) and 2 simple
scripts. one to set a language cookie and the second one to redirect
according to the language cookie.

Jul 17 '05 #3
this is just pseudo-php code to get an idea of what should be done.

# add the 404 error handling to apache with .htaccess
ErrorDocument 404 /404.php

# setlang.php to create a language cookie
setcookie("lang", $_GET['lang'], .....)

#the 404 handler
header("Location: http://www.example.com/" . $_COOKIE['lang'] . "/" .

to make it work, links must point to a non-existent file.

Jul 17 '05 #4
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_exist s($_GET['lang'],$translations)

// check that variable exists in url
$lang = $_GET['lang'];
$lang = $translations["en"];
ini_set("include_path", "/path/to/www/root/".$lang."/");
// change path to your path
$id = $_GET['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">

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: GD | last post by:
I'm using a script that works great on IE, but not on mozilla. the original one worked also on N4, but i'd like it to be funcional with mozilla. this is the orginal script: ...
by: Uttam | last post by:
Hello, I created and worked on my application on my desktop and copied it to my laptop. After putting in many additions to the functionality on the Laptop version, I copied it back to my...
by: Michael Johnson Sr. | last post by:
I have an application which I developed in C# ASP.NET. It uses SQL Server which is on a Virtual PC using Virtual PC 2004. It works great, no problems. I moved the user controls, aspx files,...
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
by: rick | last post by:
Hi I m trying to move only stored procedures from one database to another and also onto a database on another server, I tried db2 -x "select text from syscat.procedures where procschema =...
by: JoshG | last post by:
Hello, We are researching whether the following scenario would be possible: In an upcoming application release, we have to move some tables (Log tables, look up tables, and a couple of secure...
by: GS | last post by:
How do I properly detect row change before allowing moving to next row? I tried using RowLeave . here is brief descript of the form setup. I have ieStringTmpDataSetwith regex table...
by: linkswanted | last post by:
We are your trusted source. World Moving & Storage is bonded and licensed by the U.S. Department of Transportation and is one of the largest residential moving and corporate relocation company in...
by: =?Utf-8?B?TWFyaw==?= | last post by:
I modified a C# application from Bob Powell that moves graphics primitives around on the screen into a Vb.NET 2005 application. I want to modify this application so along with moving regular...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.