Apache follows symlinks in unexpected ways on Dreamhost

October 15, 2006 Link to post  Permalink

I don’t know if this is just Dreamhost, I suspect its a general Apache thing, but following a Symlink for a directory doesn’t work the way I expected, so to help others avoid this problem, here’s the simple fix.

My Setup

I have an app in ~/my.domain with a directory called ‘something’ that is being served by Apache. Inside this directory are a bunch of other directories with files. The real ones were served fine, but the symlinked directories were causing 403 errors when I requested a file.

http://my.domain/something/real-dir/a-file works ok, but http://my.domain/something/symlink/a-file fails.

I do have the Options FollowSymLinks line in my .htaccess file.

Now to serve files for this app, the permissions need to be set to 755, and I’d set ‘something’, ‘real-dir’ and ‘symlink’, and their contents, to be 755, but still I’m getting errors.

The Fix

It turns out that I also need to set the real parent of ‘symlink’ to be 755 as well. Once I’d done this, files are flowing again.

I spent 2 hours on this, so you don’t have to!