473,625 Members | 3,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

http://www.mydomain.com/apage.html

to

http://www.mydomain.com/fr/apage.html

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

http://www.mydomain.com/apage.html

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 1647
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
<?php
setcookie("lang ", $_GET['lang'], .....)
?>

#the 404 handler
<?php
header("Locatio n: http://www.example.com/" . $_COOKIE['lang'] . "/" .
$_SERVER['REQUEST_URI'] . "");
?>

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_ex ists('lang',$_G ET)&&array_key_ exists($_GET['lang'],$translations)

// check that variable exists in url
$lang = $_GET['lang'];
else
$lang = $translations["en"];
ini_set("includ e_path", "/path/to/www/root/".$lang."/");
// change path to your path
if(array_key_ex ists('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.co m"> 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

6
1517
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: ***************************** <Head> <script language="JavaScript1.2"> var menu1top=230
0
2412
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 desktop. Nothing was changed on the desktop in respect of the configuration but I now get an error which I am unable to fix. I have a statement "Set cat = New ADOX.Catalog" This statement is
0
1178
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, dll, and other important files to Windows 2003 Server, then I created a virtual directory in IIS. When I view the site, I get an error message saying trust levels won't allow debug mode. So i modified the web.config and set debug = "false". Then I...
2
3103
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 connecting the two shapes. http://www.blackwaterbadgers.co.uk/image1.bmp Image 1 shows how if you have a line between two shapes, the line is straight. if you have more than one line, the lines will start overlapping
8
8680
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 = 'MYSCHEMA'" | tee /esa/home/sasha/MY_SCHEMA_SP.txt, how ever all the procedures are getting loaded to the file but some stored procedures are getting truncated because they are too big , I also tried to use getroutine but the problem is we have 600...
3
1747
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 tables) from database A to database B. Rather than wait and do everything all at once, and have no roll-back plan should it fail, we'd like to create database B now, and start
2
4181
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 connected to a SQL mdf., on the form I have a regexDataGridView for the table regex for navigation and viewing purpose only
0
1841
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 the country. allows you to easily obtain no obligation moving quotes from local movers, long distance movers, international movers, auto transport, storage rentals and specialty movers. office movers, commercial moving, residential moving, movers...
12
1914
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 geometric shapes, I can also move the alphanumeric characters as well. For example I place the character "A" on the screen and when I point to it with the mouse the character will be outlined and while holding down the left mouse button move the "A"...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.