Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 625227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:17:13+00:00 2026-05-13T19:17:13+00:00

I have the following code: <html> <head> <title><?php echo $GLOBALS[‘L’][‘title’]; ?></title> </head> <body> <ul

  • 0

I have the following code:

  <html>
        <head>
            <title><?php echo $GLOBALS['L']['title']; ?></title>
        </head>
        <body>
            <ul id="language-selection">
                <li><a href="index.php?lang=english">English</a></li>
                <li><a href="index.php?lang=french">French</a></li>
            </ul>
            <h1><?php echo $GLOBALS['L']['h1']; ?></h1>
            <p><?php echo $GLOBALS['L']['p1']; ?></p>
            <ul id="language-selection">
                <li><a href="about.php">About Page</a></li>
                <li><a href="contact.php">Contact Page</a></li>
            </ul>
        </body>
    </html>

set_locale.php:

<?php
/*
 * File: set_locale.php
 */

// Get the language from the query string, or set a default.
($language = @$_GET['lang']) or $language = 'english';

// Set up a list of possible values, and make sure the
// selected language is valid.
$allowed_locales = array('english', 'french');
if(!in_array($language, $allowed_locales)) 
    $language = 'english'; // Set default if it is invalid.


// Inlclude the selected language
include "locale/$language.php";

// Make it global, so it is accessible everywhere in the code.
$GLOBALS['L'] = $locale;
?>

It works OK, but if I click the about.php and contact.php link.
The page returns to the default language: English.
What can I do so that when I click about.php or contact.php ends up like this:

about.php?lang=english
contact.php?lang=french

respectively, in other words I want the URL to remember the ?lang= ending.
What’s the best way of doing it?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:17:14+00:00Added an answer on May 13, 2026 at 7:17 pm

    You’ll have to append it to every outgoing link:

     <li><a href="about.php<?php echo "?lang=".$GLOBALS['L']; ?>">About Page</a></li>
    

    a nice way of dealing with multi-language sites in general is, if your server supports it, mod_rewrite to rewrite “virtual” URLs like

    www.example.com/en/about.php
    

    and map them internally to

    www.example.com/about.php?lang=en
    

    there’s a beginner’s guide on that here and official documentation here.

    I’m no mod_rewrite guru but this works for me:

     RewriteEngine on
     Options +FollowSymlinks
    
     RewriteCond %{REQUEST_URI} ^/([a-z][a-z])(/.*)?$      
     RewriteRule (.*) %2?lang=%1&%{QUERY_STRING}
    

    it maps

    • www.domain.com/en/about.php to /about.php?lang=en

    • www.domain.com/fr/about.php to /about.php?lang=fr

    • www.domain.com/es/ to /?lang=es = usually index.php

    It maps any occurrence of a two-letter, lowercase www.example.com/xy, so you shouldn’t have any directories with two letters on your root level to work with this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code sample upload3.php: <html> <head> <title>PHP Form Upload</title> </head> <body>
I have the following code: <!DOCTYPE html> <html > <head> <title>Distance</title> </head> <body> <?php
I have the following HTML Code <%@ Page Language=C# %> <html> <head> <title></title> </head>
I have the following code <xsl:result-document href=output1/output3/index.html format=html> <html> <head> <SCRIPT LANGUAGE=JavaScript> function getParams()
I have a file test.php with the following code: <html> <head> <title>Listing 10.2 </title>
I have the following code: index.html <HTML> <HEAD> <TITLE>My App</TITLE> <LINK rel=stylesheet type=text/css href=style.css>
I have the following html and css code: <!DOCTYPE HTML> <html> <head> </head> <body>
I have the following html/php/javascript code: <?php $textBox1 = $_POST[textBox1]; ?> <html> <head> </head>
I have the following code: <html xmlns=http://www.w3.org/1999/xhtml lang=en xml:lang=en> <head> <title>Image uploader</title> </head> <body>
I have the following snippet of the code: <html> <head> <title>Example of Very First

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.