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 6724771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:43:44+00:00 2026-05-26T09:43:44+00:00

I currently have a pretty straight forward modrewrite file that maps urls to different

  • 0

I currently have a pretty straight forward modrewrite file that maps urls to different php pages with possible GET variables:

RewriteRule ^grant$ about.php?p=4 [L]
RewriteRule ^contact-people-([A-za-z0-9-]+)$ about.php?p=5&to=$1 [L]
RewriteRule ^([a-z0-9-]+)-media$ media-gallery-element.php?prettyid=$1 [L]
#etc .... it goes on for perhaps 200 or so entries

I want to have a global language variable that is in the url and I’m wondering how I can smartly adjust my modrewrite file to handle this. I could do it by doubling my entries and just add more rules such that the first one above gets changed to:

RewriteRule ^grant$ about.php?p=4&lan=en [L]
RewriteRule ^([a-z]+)/grant$ about.php?p=4&lan=$1 [L]

The first row is just the same and would default to english (en) and then the second row handles other language codes, es, fr, de, etc. So I could do it this way, but it seems like there is a better way to do this without doubling my entries. Basically, I want to take ALL of my requests, look for a ([a-z]+)/ at the beginning of the request uri, and then tack that onto the request as a GET variable, lan.

How do I do this smartly?

  • 1 1 Answer
  • 0 Views
  • 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-26T09:43:45+00:00Added an answer on May 26, 2026 at 9:43 am

    You can do this easily by setting an environmental variable. Something like this should do the trick:

    # set default environmental variable for language
    RewriteRule .* - [E=language:en]
    
    # if two characters and slash lead, then
    RewriteCond %{REQUEST_URI} ^/([a-z]{2})/(.*)$     
    
    # overwrite default environmental variable
    RewriteRule .* - [E=language:%1] 
    
    # other rules
    RewriteRule ^grant$ about.php?p=4&lan=%{ENV:language} [L]
    

    You can also access the environmental variable directly in PHP, in which case you could skip including it in the rewrite rules:

    echo getenv('language');
    echo $_SERVER['language'];
    echo $_SERVER['REDIRECT_language'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, currently I have my SWF hitting a php file that will go and
It seems pretty straight forward to get what I want. The data details display
I am currently writing an financial application, and we have a pretty standard customer
I currently have an MS Access application that connects to a PostgreSQL database via
I have a PHP based web application which is currently only using one webserver
This seems pretty straight forward but I'm not sure what is going wrong. I'm
Well... I am a n00b, I know that. And this is pretty straight foward.
Pretty straight-forward, but don't really know if it's even feasible. Basically I'd like to
I have a pretty standard table set-up in a current application using the .NET
I currently have speakers set up both in my office and in my living

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.