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

  • Home
  • SEARCH
  • 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 6964253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:05+00:00 2026-05-27T15:54:05+00:00

i try to look on stackoverflow but i can’t find my answer. so i

  • 0

i try to look on stackoverflow but i can’t find my answer.

so i need to find out which domain which sub-domain the user is and which page is loading.

eg: en.domain.com/contactus

this should load the english contact us page.

what i have is:

RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^(.*)$ index.php?lang=en&page=$1 [L,NC]

RewriteCond %{HTTP_HOST} ^en.domain.com$ [NC]
RewriteRule ^(.*)$ index.php?lang=en&page=$1 [L,NC]
RewriteCond %{HTTP_HOST} ^fr.domain.com$ [NC]
RewriteRule ^(.*)$ index.php?lang=fr&page=$1 [L,NC]
#etc...

but for some reason when i echo the get for page, the value is : index.php so i cannot read the page.

  • 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-27T15:54:06+00:00Added an answer on May 27, 2026 at 3:54 pm

    Here’s what you should use:

    RewriteEngine On
    RewriteBase /
    
    SetEnvIf Host ^www\. lang=en
    SetEnvIf Host ^en\. lang=en
    SetEnvIf Host ^fr\. lang=fr
    
    RewriteCond %{REQUEST_URI} !\.(css|png|gif|jpe?g|js)$ [NC]
    RewriteRule ^([a-z0-9_\-]+)/?$ index.php?lang=%{ENV:lang}&page=$1 [L,NC,QSA]
    

    The %{ENV:lang} will be read from the SetEnvIf (from the sub-domain) and set the correct language you will get from $_GET['lang']; (in your PHP code – assuming it’s PHP)

    This way, any of the sub-domain will be dynamically loaded without creating rules over and over for sub-domain. I also added a rule that prevent loading images or JavaScript as page.

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

Sidebar

Related Questions

Not as in can't find the answer on stackoverflow, but as in can't see
Look at the image above and try the url at -> http://domainsoutlook.com/s/site/stackoverflow.com.html and go
I have a question which I think should be pretty common but I can't
I'm new to using the NetBeans IDE. When I try to look at the
When I try to use introspection to look at what methods are available on
Take a look that the following code snippet: A a = null try {
I try to define a schema for XML documents I receive. The documents look
There are a lot of websites that look professional in Google results. Try searching
When i try to look for a location like this: Florida,USA it goes OK,
I've look around and I haven't find anything in the Web pointing me to

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.