I have a script that is available through Apache that modifies parent directory. Ew. mybin/a.pl, which modifies ../data/ directory. I would like to create various aliases eg. localhost/www/mybin/a.pl localhost/zzz/mybin/a.pl 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?

2 Answers 2


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.

  • This explanation is exactly what I needed. Thanks!
    – agsamek
    Aug 27, 2011 at 17:08

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

  • works same with or without this option
    – agsamek
    Aug 27, 2011 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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