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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:19:02+00:00 2026-05-18T07:19:02+00:00

I have a bunch of domains pointing to the same folder, the root of

  • 0

I have a bunch of domains pointing to the same folder, the root of my host “public_html”.
I wish I could redirect them, each one for a folder with the same name as the domain.

eg: redirect http://www.mydomain.com to “public_html/www.mydomain.com”

I tried this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/%{HTTP_HOST}/.*$
RewriteRule ^(.*)$  /%{HTTP_HOST}/$1 [L]

But with no success. What’s wrong?
Its even possible to redirect to folder that uses a ‘dot’ on its name?

Thanks in advanced.

  • 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-18T07:19:03+00:00Added an answer on May 18, 2026 at 7:19 am

    The test pattern in your RewriteCond is actually trying to match input starting with the literal string /%{HTTP_HOST}/. The value of the %{HTTP_HOST} variable is not expanded like you were expecting, so the condition will always be true (the pattern itself will never match). You’ll need to modify the RewriteCond, and there are a few different approaches.

    If this is the only rewrite you perform, you can just check to see if you’ve done it yet:

    RewriteCond %{ENV:REDIRECT_STATUS} =""
    

    Or, if the resource won’t exist until you rewrite it, you can check for that instead:

    RewriteCond %{REQUEST_FILENAME} !-f
    

    Finally, you can mimic your original condition by using backreferences within the test pattern, along with a separator character that won’t appear in your URL:

    RewriteCond /%{HTTP_HOST}/#%{REQUEST_URI} !^([^#]+)#\1
    

    Note that this doesn’t guarantee that you’ve done the redirection though, it only ensures that the request URI has the host name as its first path segment. However, that’s generally good enough.

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

Sidebar

Related Questions

I have a bunch of divs with weird id and each of them contains
I have an htaccess redirect set up for a bunch of domains to all
My domain model is this: we have a bunch of schools as the root
I have a bunch of files in a folder checked out from a repository.
I have a bunch of strings that are dependent on static dictionaries and each
I have the following bunch of domains: myDomain.de myDomain.com myDomain.co.za myDomain.org myDomain.com myDomain.com.na What
I have a bunch of rules in my .htaccess (sub-domains, folders, users specific folders
I currently have a bunch of urls to redirect to their new urls: I
I have a bunch of files in the web root: - /abc-674.php /def-643.php etc.etc.
To explain the domain... I have a bunch (1,000,000) of items, each of a

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.