Hi,
I've been seeing a lot of this question in the thread but didn't find any answer.
I want to change the document root of our primary domain from public_html to public/html/new_folder.
Is there any way I can do this in Cpanel?
As PlatinumServerM told you in a previous post above, you can make
this change by altering the VirtualHost information for the account in
the main Apache configuration (/usr/local/apache/conf/httpd.conf) ...
The question is not so much "if you can" as "if you should"?
I have at various times needed to change the default document root
to different folders for one reason or another and it works fine in doing
so but my experience has been that you tend to forget about such
custom changes and can run into some major headaches later when
trying to maintain compatibility or going through software updates.
A better suggested way of doing this may be to create a symlink on
the acount much the same way "www" by default points to "public_html"
to maintain compatibility with users who are more used to other servers
that use "www" as the root web account folder. You can create the
same kind of symlink and direct that to whatever folder structure you wish
and accomplish the same thing instead of updating Document Roots or
implementing complicated web redirects with mod_rewrite commands, etc.
In example:
Code:
# cd /home/(username)
# mkdir ./public
# mkdir ./public/html
# ln -s ./public_html ./public/html/new_folder
Now I don't know if you are requesting this change because you do not
want "public_html" to appear in the URL or some other reason. If the former
is the case, then I would be pleased to let you know that you have made a
wrong assumption (and a fairly common mistake make by most new users)
assuming FTP structure where you upload your files is the same as the
web structure when you view your pages but is actually one level higher.
More specifically ...
When uploading files to /public_html, your files are not located at /public_html
out on the internet, on the web, but rather at the root (/) of your domain.
In FTP upload example: Uploading 'test.html' to /public_html folder
This file on the web, would be:
http://www.yourdomain.com/test.html
A lot might think (incorrectly), the file would be at
http://www.yourdomain.com/public_html/test.html
but this idea is actually wrong and a bad assumption made by many new users.