Using symbolic link directories with Apache, PHP and Windows 7

18,906

Solution 1

Why not just use Alias in Apache to achieve what you want rather than using NTFS SymLinks?

Put this in your httpd.conf:

Alias /inc "C:/inc"

<Directory "C:/inc">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

Solution 2

Creating the symlink using an absolute path did the trick for me.

mklink /D C:\path\to\symlink C:\path\to\existing\folder
Share:
18,906

Related videos on Youtube

chawkinsuf
Author by

chawkinsuf

Updated on September 17, 2022

Comments

  • chawkinsuf
    chawkinsuf over 1 year

    I am trying to setup a symbolic link for a directory and I am getting the strangest error. I am using:

    mklink /d C:\www\site\inc C:\inc

    where C:\inc\script.php is the file I need to run. This seems simple enough, and it does work the first time I execute the script (by accessing http://localhost/inc/script.php). After that however, I get an error and cannot get the script to execute successfully again until I delete and recreate the symbolic link (even shutting down Apache or restarting Windows has no effect).

    Note that everything else is running normally, the symbolic link does work, and Apache does have permission to access C:\inc and also has FollowSymLinks enabled. Here is the error I am getting:

    Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

    Fatal error: Unknown: Failed opening required 'C:/inc/script.php' (include_path='.;C:\php5\pear') in Unknown on line 0

    Does anyone know what the deal is with the Unknown on line 0, and why would it execute exactly one time before giving this error?

    • Admin
      Admin almost 13 years
      all whats needed is Capital D and must be running cmd line as admin
  • chawkinsuf
    chawkinsuf over 13 years
    I tried using an alias, but the problem is there is a rewrite rule that redirects everything that is not a file or directory to index.php (RewriteCond %{REQUEST_FILENAME} !-f & RewriteCond %{REQUEST_FILENAME} !-d). This is a system that was originally designed on Linux (where the sym links work fine), so I would rather not clutter up the rewrite rules to exclude specific directories (there are actually multiple /inc directories I need to get access to).