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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:43:46+00:00 2026-05-31T23:43:46+00:00

I am trying to match certain rules Only when there is no locale in

  • 0

I am trying to match certain rules Only when there is no “locale” in the query string

Here is how i am doing it:

RewriteCond %{QUERY_STRING} !locale
RewriteRule ^acceuil$ home.php?locale=fr [NC,L]
... (More rewrite rules)

Basically i want /acceuil to go to home.php?locale=fr (Working perfect)

Except that if somehow a link was like this /acceuil?locale=en i would like to make it go instead to /home which is equivalent to home.php?locale=en

Any chance to rewrite lets say “/acceuil” in the following way :

if(isset($locale)) {
      go to home.php?locale=$locale
}
else{
      go to home.php?locale=fr
}

Also i am wondering if the condition should be copy pasted before each rule ?

Please let me know if this is possible, and how i can get it going, if you have some useful reference for htaccess rewrites please share 🙂

Thanks

  • 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-31T23:43:47+00:00Added an answer on May 31, 2026 at 11:43 pm

    Here’s a generic rule that should work, and that makes sure the variable in the GET is locale (not localeee neither llllocale):

    RewriteCond %{QUERY_STRING} (^|&)locale=([a-zA-A]+)(&|$)
    RewriteRule ^acceuil$ home.php?locale=%1 [L,NC,QSA]
    
    # if locale = en ...
    RewriteCond %{QUERY_STRING} (^|&)locale=en(&|$)
    # ... and it goes to home.php then go back to /home:
    RewriteRule ^home.php$ /home [L,NC,QSA]
    

    Note: if it’s French then it’s Accueil, not Acceuil 🙂

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

Sidebar

Related Questions

I'm trying to extract only certain elements of a string using regular expressions and
Possible Duplicate: XPath: How to match attributes that contain a certain string I'm trying
I am trying to match floating-point decimal numbers with a regular expression. There may
I'm trying to match the following items in the string pcode : u followed
I'm trying to match chunks of JS code and extract string literals that contain
Below I'm trying to match certain nodes. <xsl:template match=nodes> <element> <xsl:apply-templates select=nodes mode=different />
I am trying to see if a string contains certain text and if so
I am working with 3 tables, trying to pull a list that match certain
I'm trying to find certain keywords in a string with python. The string is
Can a regular expression match whitespace or the start of a string? I'm trying

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.