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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:00:36+00:00 2026-05-15T08:00:36+00:00

I am having a problem making a sub directory act as the public_html for

  • 0

I am having a problem making a sub directory act as the public_html for my main domain, and getting a solution that works with that domains sub directories too.

Background

My hosting allows me to host multiple sites, which are all working great. I have set up a subfolder under my ~/public_html/ directory called /domains/, where I create a folder for each separate website. The folder structure on my server looks something like this:

  • public_html
    • domains
      • websiteone
      • websitetwo
      • websitethree
      • …

This keeps my sites nice and tidy. The only issue was getting my “main domain” to fit into this system. It seems my main domain, is somehow tied to my account (or to Apache, or something), so I can’t change the “document root” of this domain. I can define the document roots for any other domains (“Addon Domains”) that I add in cPanel no problem. But the main domain is different.

The problem

I was told to edit the .htaccess file, to redirect the main domain to a subdirectory. This seemed to work great, and my site works fine on it’s home/index page.

The problem I’m having is that if I try to navigate my browser to say the images folder (just for example) of my main site, like this:

http://www.yourmaindomain.com/images/

then it seems to ignore the redirect and shows the entire server directory in the url, like this:

http://www.yourmaindomain.com/domains/yourmaindomain/images/

It still actually shows the correct “Index of /images” page, and shows the list of all my images. It’s just the “pretty” URL that’s the problem.

Example of my .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteCond %{REQUEST_URI} !^/domains/yourmaindomain/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domains/yourmaindomain/$1

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ domains/yourmaindomain/index.html [L]

Does this htaccess file look correct? I just need to make it so my main domain behaves like an addon domain, and it’s subdirectories adhere to the redirect rules.

  • 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-15T08:00:37+00:00Added an answer on May 15, 2026 at 8:00 am

    Don’t use mod_rewrite for that, use virtual hosts for that. I won’t explain that here in detail, you’ll find all the necessary information at the above link. (Hint: You’ll need the name-based ones probably.)

    You probably want to move your stuff out of ~/public_html/ to some more generic place like /var/www/ or /srv/www.

    Besides that: Don’t use .htaccess files on production.

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

Sidebar

Related Questions

I am having small problem in making a global variable works. I am using
I am having a strange problem while making app requests. I understand that when
So I'm having a problem making a new socket. I had this program that
I'm having some difficulties with the following problem: I'm making a little game where
I'm having a little problem while making a game, and while the problem is
I am making a WPF program that contains a TreeView. I am having a
Been having a problem making a jQuery slider, I have a list of links
I am having problem when making a long scroll view with images. It will
I'm having a problem with making a sha1-hash of a row in a select
I'm having a problem with making one div overlap the rest of the page.

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.