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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:21:32+00:00 2026-06-09T07:21:32+00:00

I’m attempting to fix some annoyances with my current shared host configuration, but I’m

  • 0

I’m attempting to fix some annoyances with my current shared host configuration, but I’m having a few issues getting everything set up as I want it.

Currently, I have the following folder structure:

/
/.htaccess
  /example
  /example1
  /example2
  /example3

On the shared host, the primary domain is automatically set up to point to the root directory. In an effort to point the primary domain to a subdomain, I added the following to my root file’s .htaccess:

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

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{REQUEST_URI} !^/example/
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/ [L]

This properly rewrites the URL so that going to example.com displays the content from the /example/ subdirectory. The problem is that subdirectories of the root are not being rewritten in the same way, which is not the functionality that I was hoping to achieve. Example:

http://www.example.com/            = /example
http://www.example.com/example/    = /example
http://www.example.com/example1/   = /example1
http://www.example.com/example2/   = /example2
http://www.example.com/example3/   = /example3

What I want to happen is the following:

http://www.example.com/            = /example
http://www.example.com/example/    = /example/example
http://www.example.com/example1/   = /example/example1
http://www.example.com/example2/   = /example/example2
http://www.example.com/example3/   = /example/example3

My understanding of what should happen is as follows:

  1. Request for http://www.example.com received.
  2. First condition fails to match, HTTP_HOST does not match ^example.com$
  3. Second condition: matches ^www.example.com
  4. Third condition: no REQUEST_URI, so it matches not ^/example/
  5. Fourth and fifth: I’ve tried with and without these, but it didn’t seem to change the result. My understanding is that if those lines are uncommented, I would see the unwanted before I’m having right now (if the filename and directory exist, the rewrite would not take place).
  6. Rewrite the request to example.com/example/
  7. Sixth condition: match the URL to a specific domain.
  8. Always rewrite to use the /example/ subdirectory for this URL.

This does appear to work, but if I try to go to http://www.example.com/example2/, I get the problems. Since the REQUEST_URI doesn’t match /example/, my thought was that it should be rewriting to /example/example2, but that obviously doesn’t happen.

I don’t have access to the Apache configuration or the ability to set up VirtualHosts, so I’m hoping there’s some way that I can do this with .htaccess rules. Any insight into how I’m over-complicating this simple task would be extremely helpful.

  • 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-06-09T07:21:34+00:00Added an answer on June 9, 2026 at 7:21 am

    As far as I could tell, the .htaccess file in my root was being ignored if a directory in the root matched the request that was coming in (that is, if example1 existed in the root directory, putting a RewriteCond to rewrite /example1 to an error page was never triggered).

    My solution to this ended up being a bit less elegant than I had hoped, but it seems to be working. Hopefully it can help anyone else who stumbles onto this issue.

    Inside of the example1, example2, and example3 directories, I modified the .htaccess file to include the following (changing example1 based on the directory):

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

    This forces the main domain to serve the content that is within the sub-directory I had created for it, even if there is a matching directory in the root.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.