Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that is available through Apache that modifies parent directory. Ew. mybin/, which modifies ../data/ directory. I would like to create various aliases eg. localhost/www/mybin/ localhost/zzz/mybin/ that would modify different directories - like www/data and zzz/data. I would like to keep one version of mybin. I tried to create symbolic links www/mybin and zzz/mybin which point to a single directory (main/mybin). The problem is that apache resolves symbolic links and exectues the script in main/mybin regardless of the path. Is it possible to configure apache so that my script is called from within the symbolic link?

share|improve this question
up vote 2 down vote accepted

I don't think the answer is going to be found in Apache but rather in the CGI itself. Apache will follow symlinks provided the owner is the same, that said I would look at your CGI script which you haven't provided.

My guess is that you're using relative path when referencing the data directory you're script modifies. If you're going to be using the script with symlinks than this is not an ideal situation and ill-advised as the relative path will always be the same as it will be performed from the file itself not the symlink location.

What I typically do when I'm trying to do something like this is use the SCRIPT_FILENAME CGI environment variable that Apache passes along. This should have the path that was called which will be the symlink location. This path will be an absolute path from /. This will have the CGI script name so you can strip that and then append ../data or get the base directory name from the path info to determine the proper data directory.

share|improve this answer
This explanation is exactly what I needed. Thanks! – agsamek Aug 27 '11 at 17:08

You can make Apache don't follow symbolic links with Options -FollowSymLinks in the directory which you want.

share|improve this answer
works same with or without this option – agsamek Aug 27 '11 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.