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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:36:04+00:00 2026-05-31T09:36:04+00:00

Possible Duplicate: Apache rewrite based on subdomain Is it possible to rewrite a URL

  • 0

Possible Duplicate:
Apache rewrite based on subdomain

Is it possible to rewrite a URL like this?

www.foo.website.com/some-page

to

www.website.com/some-page?var=foo

I’m asking about a rewrite (I think that’s what it’s called) and not a redirect. i.e. I want the first URL to stay in the address bar, but for the server to “get” the second URL.

I’ve never understood how to do URL rewrites and so far my pathetic attempts to get this working have failed miserably 🙂

I should add that this .htaccess file is also being used by WordPress and has the following code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~kbj/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~kbj/index.php [L]
</IfModule>

Any help or advice would be very much appreciated!

  • 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-31T09:36:05+00:00Added an answer on May 31, 2026 at 9:36 am

    What I’ll explain is for multilanguage websites, but you can very easily apply this to what you’re asking: rename “LANGUAGE” to “var” (smile).

    Here’s what you may want to do, to be able to handle in the future many sub languages.
    Check your host: if it contains a “known language”, add it in a global variable (= environment variable from Apache’s point of view) then at the end, if the “language” variable is not set, set is as the default language. And finally, add it as a parameter.

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.website\.com$
        RewriteRule ^(.*)$ "http://www.website.com/$1?var=%1" [P]
    
        RewriteCond %{HTTP_HOST} ^(www\.)?(us|fr|pt)\.mydomain\.com$
        # Create an environment variable to remember the language:
        RewriteRule (.*) - [QSA,E=LANGUAGE:%2]
        # Now check if the LANGUAGE is empty (= doesn't exist)
        RewriteCond %{ENV:LANGUAGE} ^$
        # If so, create the default language (=es):
        RewriteRule (.*) - [QSA,E=LANGUAGE:es]
        # Add the language to the URI (without modifying it):
        RewriteCond (.*) $1?language={ENV:LANGUAGE} [QSA]
    
    </IfModule>
    

    (note: please, please… use proper indentation).

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

Sidebar

Related Questions

Possible Duplicate: How to rewrite URL without refresh, like GitHub.com Hi all, I have
Possible Duplicate: Opening url in new tab while i am doing window.open(), my page
Possible Duplicate: apache redirect from non www to www Is it possible to configure
Possible Duplicate: How to: URL re-writing in PHP? How can a website use an
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: php == vs === operator Reference - What does this symbol mean
Possible Duplicate: C# driver development? I would like to know if I can do
Possible Duplicate: How to enable PHP short tags ? I am using Apache Friends
Possible Duplicate: How would I identify if a website originates from a mobile browser?

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.