Change Docroot To Custom folder with capital letters in HTTPD Configurations

apple58

Verified User
Joined
Dec 31, 2021
Messages
22
I have recently installed and begun using Directadmin (so the latest version as of today is installed). I previously have used cPanel, and I find that most of the features are equivalent. I have several domains that have been set up on a VPS. There is a feature in cPanel (and Plesk) that is not natively a part of DA, but was added about two years ago, according to discussion at https://forum.directadmin.com/threads/domains-and-subdomains-pointing-to-specific-folder.1956/

This feature allows you to set a custom Document Root location, which can be within the public_html folder that was created by DA when making the domain. It can also be elsewhere. On one website I have, I have used the admin-->HTTPD configurations-->customize, and used the following customization code in the main section: |?DOCROOT=/custom/document/root|, replacing the address with the full path, from home, to the folder.

Initially, the subfolder had a capital letter in it, and I was getting a Page not Found error after adding this. Then, I found a DA forum post ( https://forum.directadmin.com/threads/custom-docroot-error-with-capital.62570/) that says that I cannot use capitalized folder letters in the docroot path. When I changed the folder name, and the corresponding defined path, to not have capital letters, the website serves the right page.

However, for another domain on this same VPS, I have a large number of folders on the server, almost all of which have capital letters in the folder name. Many of the folders contain php files which call other folders, which are also capitalized. This has not caused any issues in the past. So, when I try to use the customization above, it comes back with a page not found, which is apparently the capitalization error.

The path to the index file on this particular domain is within two subfolders, both of which have a capital letter in their folder names, which, as I said, cannot be changed. I have moved this very same server from another hosting provider, where it was using cPanel. This issue does not exist in cPanel, as one can have as many capital letters in the folder names that you want.

Is there some way that this can be worked around? Perhaps there is an Apache setting that has to be added (I think it was called differentiation on other servers) to allow the use of capital letters in the path to the index file? Thank you in advance for you help.
 
Using folders with capitals is in fact no problem, but Linux is not Windows. It's case sensitive and has always been like that.
If CP found an option to ignore that then this is up to them.
Even in my time as user (not admin) I had to take that in mind. So you can use capital folders not doc-root but they should be made by the system anyway and not by the user) and if called the correct way, it would not give any issue at all.

This issue does not exist in cPanel, as one can have as many capital letters in the folder names that you want.
I thought it did. At least some years ago it still did and in fact it should, imho.
Because Apache is doing this too. And as long as users can not create the public_html root there is no issue. Users should point in their scripts to the correct directory's in correct case sensitivity.

However, if I'm not mistaken one can change that in a custom way. I found a thread which contains a solution (last post) which might also fix your issue.
 
Thanks very much for your help. Unfortunately, this web server does not use openlitespeed, so the only .conf file in the domain area is httpd. When I edited the first Custom field (since there are only four, and none of them say that they are for the rewrite rule), also adding the docroot command, when I point to the website, there is just a white page. Is there a command specifically for apache, or perhaps which of the custom fields should I have added the code to? None of them seemed to be correct. There are only four, rather than 8 as OpenLiteSpeed would have.

Thanks in advance for your help.
 
Perhaps you can tell me if there is a specific way to set the htaccess file in the outside folder, that it would point to an internal folder when the page is opened. I have tried multiple permutations of the htaccess file, and none of them have worked. All I need to do is point the entire webpage to a specific folder on the server. One of the last things I tried was:

"Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ /SubFolder1/Folder [R=302,NC,L]"

Prior to that, I had tried to use the following, which had worked on the shared hosting server this site was ported from:

"
Options +FollowSymlinks
RewriteEngine on

RewriteRule ^$ /SubFolder1/Folder [L]"

That is what was working in the past, using a shared server. In the subfolder, there is another htaccess file that instructs the browser where to land (on the php file that calls the other php files). Since this is a large website, with many pages, it was designed in modules. So there is a headertop module, a headerbottom module, a text file, and a main php file that calls all the other files.

I am not an expert at using apache, so I have not been able to see how to change the htaccess file. With these htaccess files loaded, I get what appears to be the spelling error (that it cannot parse capital letters- and returns the File Not Found page). I used another domain on the same server, which also had capitalized folders, that I was able to easily uncapitalize, and it fixed the issue.

This has not been so with this domain. When I change the filenames to lowercase instead of capitalized, then I get a Forbidden error. And the permissions on all folders are correct. I am almost certain there is a simple fix for this issue, perhaps it has to do with the ssl? I say this because I had this server working properly, on a VPS with a different IP address, with the second htaccess file working properly, until I changed that server to ssl.

Since then, it has not been working at all (using other Virtualmin and Webmin). Any help would be greatly appreciated. As I said, even an htaccess workaround would be acceptable, since this is the ONLY server we have that has this issue where the Document root is not in the public_html folder, but is in an internal folder. In the past, I simply pointed other GUIs (of which I used four - cpanel, plesk, webmin, and virtualmin) to the correct document root, but this is not offered with DA.
 
When I added the Docroot code to the httpd configuration again
Are you making a custom template or editing the standatd template directly? If you wish to change anything outside of Standard DA functionality. you must create a custom template.

You should not edit the httpd.conf directly.
Read starting here
 
Are you making a custom template or editing the standatd template directly? If you wish to change anything outside of Standard DA functionality. you must create a custom template.

You should not edit the httpd.conf directly.
Read starting here
Yes, I was adding the docroot statement in the customization under httpd configs.

I put the code mentioned (for the spelling mod) into the custom apache file that I had created using the instructions for how to do that in DA. I have not edited the httpd conf file directly. Thanks!
 
I tried another test today on this same website. I made the folder names lowercase, and I used the DOCROOT command to point the document root to that folder, where there was both an index.php file and an index.html file.

When I saved the httpd configuration with the new information, I get nothing but a blank white page. This is basically what it returns no matter what I put in that customization field, so perhaps I am placing it in the wrong place, or maybe the command is wrong. However, I have another website on this same server, using DA, and when I use the DOCROOT command (for a folder 1 level down), it recognizes the index.php file I have placed there. But on this site, when I do the same, it doesn't show either the index.php or the index.html, and there is no htaccess file in that folder. So, is the DOCROOT command I am using somehow incorrect?

This is the customization I was using:

|?DOCROOT=/home/admin/domains/mydomain1/public_html/folder1/folder-1|

Is this the correct code? Is the main customization field the correct place to put this code, or should it be put in the custom1, cutom2, or another place? Please let me know if you can provide assistance on this issue. Thanks!
 
One last update, the customization did work, my browser was caching (purging had to be done multiple times), so it was able to lead the index file. Thanks!
 
For anyone else who is having this same problem, the customization I was using was incorrect. The correct code to put in the customization field (reached by going to Custom httpd configurations in the admin area, then customize), this goes into Custom1 area:

|*if !SUB|
|?DOCROOT=/home/admin/domains/yourdomain/public_html/Subfolder1/Subfolder2|
|*endif|

Then capitalization seems to also not be an error, as the folder names can be capitalized. This is for all domains that are created in the domain management area, although it might not apply properly to the main domain (which is the hostname of the server). Thanks!
 
Back
Top