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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:33:06+00:00 2026-05-21T16:33:06+00:00

It is many topics here about subdomains but no one can help me… I

  • 0

It is many topics here about subdomains but no one can help me…

I use htacces to set subdomain to folder

So if we put http://en.example.com/something

I use something like this..

RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
RewriteRule ^(.*)$        http://example.com/%1/$1 [NC]

This works fine but adress in bar is changed to http://example.com/en/something but I want keep http://en.example.com/something

so I tried this

RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
RewriteRule  ^([^.]+)\.example\.com(.*)   /$1/$2

or just

RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
RewriteRule ^(.*)$        %1/$1 [NC]

but this doesn’t work. Any solution or ideas ?

One solution is use language there (http://example.com/en/something) where I rewrite it but after If I work on subdirectories I get something like http://example.com/subdirectory/en/something – terrible.
Maybe I like http://example.com/en/subdirectory/something bud how proceed this…

And also on some private servers first one case send me to “maybe” default domain, so it is not working for me. (maybe this is some server condition or settings)

  • 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-21T16:33:06+00:00Added an answer on May 21, 2026 at 4:33 pm

    I know this is a month late, but maybe this will still be useful for somebody. A few things here:

    Regarding your first RewriteRule:

    RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
    RewriteRule ^(.*)$        http://example.com/%1/$1 [NC]
    

    As it seems you already discovered, rewriting to another URL will also redirect the user’s browser to that new URL, even if it’s at your own domain. To keep it hidden, you have to rewrite to a file path on the server (like you do with your next two rules).

    Regarding your second RewriteRule:

    RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
    RewriteRule  ^([^.]+)\.example\.com(.*)   /$1/$2
    

    The problem there is that you can’t match the domain name in the RewriteRule, only the URL path. If your URL is http://www.example.com/something/somethingelse, the string you’re trying to match is just something/somethingelse. In other words, it excludes http://www.example.com/, so this RewriteRule pattern you have will never match the domain name because the pattern isn’t even being tested against that part of the URL, but you included the domain name in the pattern, causing the match to fail.

    Regarding your third RewriteRule:

    RewriteCond %{HTTP_HOST}  ^([^.]+)\.example\.com$ 
    RewriteRule ^(.*)$        %1/$1 [NC]
    

    This looks like it should work, so I can’t say for sure why it isn’t without knowing more about how your files are organized on the server and so forth. Let’s say you have all of the website’s files in /home/somebody/public_html/. In order for the RewriteRule to work as it is right now, you would need to have an en subdirectory in public_html. So, if somebody went to en.example.com/something, the RewriteRule would cause Apache to serve the file at /home/somebody/public_html/en/something. My guess why it’s not working for you is that you might have the subdomain pointing somewhere other than public_html (assuming you actually had the website files organized like in my example). Remember that what you’re rewriting to (/$1/$2 in this case) is a file path on the server, not a URL to your website.

    I hope that helps! You may have already solved this by now, but even if you have, I’m hoping other people will still find this useful.

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

Sidebar

Related Questions

I read many topics here about it, but can't understand why my code does
I have been reading so many topics here about this, but I could not
I've read many answers here about this topic, but everyone suggests the BCP ||
There have been many debates about this topic already here, but none of them
Yes, there are many topics about that, but I still didn't get it. I
I went through so many topics asking about Why does release build fail and
There are many topics on abstract mapping in Hibernate, but I couldn't find something
Seen many questions on same topic here, but didn't find the answer :( I've
I started learning functional programming (OCaml), but I don't understand one important topic about
There are many topics with this title, but none have helped me resolve my

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.