Get a 404 Error when using a symbolic link to private_html

highlander

Verified User
Joined
May 20, 2013
Messages
16
Hello, I am using the private_html symbolic link to public_html:

lrwxrwxrwx 1 admin admin 13 Jan 29 2013 private_html -> ./public_html

My problem is that I get a 404 error whenever I load a page using https.

I am able to solve the problem by editing:
/usr/local/directadmin/data/users/admin/httpd.conf

and changing all instances of private_html to public_html.

This is not the best solution since that httpd.conf file is auto-generated by DirectAdmin and I have to edit it every time!

I thought this problem might be related to symbolic links so I checked my httpd-directories.conf file and here's the symbolic links setting:

<Directory /home>
AllowOverride None
Options -MultiViews -Indexes +FollowSymLinks +IncludesNoExec +Includes

If it matters, here are the permissions and owners of public_html:
drwxr-xr-x 19 apache apache 4096 Jan 24 06:19 public_html
 
Symbolic link not allowed

Also, I found in the domain error log:
Symbolic link not allowed or link target not accessible: /home/admin/domains/mydomain.com/private_html

Thanks!
 
I found the problem.

First, I had to change the owner of the private_html symbolic link to apache. This got rid of a 403 error. This is strange to me since the permissions were:
lrwxrwxrwx

... all users should have had access. Does anyone know why there would be a 403 with 777 permissions?

Once that was done, to get rid of the 404 error I had to copy all the information in my htaccess file pertaining to public_html to private_html. There is some file aliasing going on in the htaccess file that needed to apply to any file in private_html. I thought the symbolic link would make this unnecessary but apparently apache applies rewrite rules to the exact directory name; it doesn't matter if the new name is a symbolic link.
 
you cant link a symbolic link to another symbolic link and It should not be 777 ever. It needs to be linked to /home/admin/domains/domain.com/public_html not /home/admin/public_html
 
I don't know why you think it's a symbolic link to another symbolic link. public_html is a regular directory.

What should the permissions be?
 
To be clear...

/home/admin/domains/mydomain.com/private_html -> ./public_html

where public_html is
/home/admin/domains/mydomain.com/public_html
 
The symbolic link was created with DirectAdmin.

It doesn't seem right that I have to have a directory entry in my htaccess file for both public_html and private_html. To me this defeats the value of the symbolic link. Shouldn't apache understand that private_html is the same as public_html because private_html is a symbolic link?
 
Yes, my SSL certificate is installed and working.

I think this problem has something to do with the server not correctly following the symbolic link.
 
I found this in the apache docs:

Be careful with the directory-path arguments: They have to literally match the filesystem path which Apache httpd uses to access the files. Directives applied to a particular <Directory> will not apply to files accessed from that same directory via a different path, such as via different symbolic links.

Seems that even if private_html is a symbolic link to public_html,

<directory "/blah/public_html">
code
</directory>

is not applied to private_html, e.g. files accessed via https and port 443
 
My approach to fix the problem was this:
<Directory ~ "/home/admin/domains/mydomain.com/(public|private)_html">

Seems odd to me that htaccess doesn't treat symbolic links as the same as the directory... oh well.

Hope this helps some future adventurer!
 
It doesn't; it shouldn't; it doesn't care, and it shouldn't need to care. It sees public_html and private_html separately because it traverses them differently. I've gotten bitten by this in the past as well.

Jeff
 
Back
Top