Symlink in URL (PHP Program)

Discussion in 'Programming/Scripts' started by Nap, Dec 2, 2006.

  1. Nap

    Nap Member

    I'm developing a website (PHP/Apache), and I need to be able to use a
    'symlink' inside a URL where the symlink points to a folder not a file.

    I have been able to use a symlink (that point directly to a file) in a url. Now I need to be able to have the symlink point to a folder (which is a parent to other content).

    I have used PHP code to generate a SYMLINK to a folder, and I have successfully tested the symlink through PUTTY. What I can't seem to do is to utilise the symlink through my browser in the url.

    When I use the symlink in the url, my server returns error 500 (internal server error) instead of 404. So something is happening.

    Can this be done?
    Is there a special way of setting up the url to make it work?
    Do I need to setup something in my .htaccess?
    Do I need to setup something in my httpd.conf or php.ini?

    Cheers,
    Nap
     
  2. sjau

    sjau Local Meanie Moderator

    You have to allow that...

    e.g.

    Code:
     <Directory /usr/local/httpd/htdocs>
    Options FollowSymLinks
    </Directory>
    
    or

    Code:
     <Directory /usr/local/httpd/htdocs>
    Options FollowSymLinksIfOwnerMatch
    </Directory>
    
     
  3. Nap

    Nap Member

    SJAU,
    thnx 4 ur reply.
    However my server doesn't have the paths you mentioned. What file / path were you refering to where I needed to make the changes?
    My machine is setup according to Falko's install for Debian Sarge and I have ISPConfig loaded.


    I also have a question about the code I used to create the SYMLINK.

    Code:
      symlink($Courses . $CourseID . '/' , $WIP . $tempdir . 'test' ); //  <=  works
      $url = $tempdir.test."/Content/1.htm";                           //  <=  works
    
    //symlink($Courses . $CourseID . '/' , $WIP . $tempdir);  // <= Doesn't work
    //$url = $tempdir."/Content/1.htm";                       // <= Doesn't work
    
      header("Location: http://www.austrisk.int/Content/WIP/$url");
    Refering to the above code, when I use putty to test the object created, the first method works but the second doesn't. (The old "Trial and Error" method was used to figure out that I needed the extra string included.)

    The only difference between the two methods is the appending of the string 'test'. Why do I need to append the string to the $tempdir variable?

    Cheers,
    Nap
     
  4. sjau

    sjau Local Meanie Moderator

    of course you need to use your paths to where symlinks should be allowed....
     

Share This Page