InMotion Hosting Support Center

By default, your primary domain document root is set as the public_html directory. This is where you can place live website files for serving to the web. Any files in this directory will be rendered and served as part of a website.

However, in some cases, a situation may arise in which a document root change is needed. For shared servers, it is necessary to contact Live Support. However, VPS and Dedicated hosting customers with root access can use the steps mentioned in our full guide on Changing the Document Root for Your Domain. This is considered advanced server administration because it involves editing your Apache configuration.

In this article, we will show you an easier way to accomplish a document root change without requiring root access or editing your system's configuration files. We will show you how to redirect your primary domain to a subdirectory. With the redirect code we provide below, users landing on your primary domain will be redirected to the contents of a subdirectory of your choice.

  1. Log into cPanel
  2. Under Files choose File Manager
  3. Edit the .htaccess file
  4. Add the following code to the .htaccess file:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?$
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /subdirectory/$1
    RewriteCond %{HTTP_HOST} ^(www.)?$ 
    RewriteRule ^(/)?$ subdirectory/index.html [L]

    Making sure to substitute for your primary domain and subdirectory for the subdirectory to which you are redirecting the domain.
  5. Save the file by clicking Save Changes

Well done! You have completed this tutorial. Now, users landing on your domain will be redirected to the subdirectory you selected.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!