Create a symbolic link on Windows 1

Today I created symbolic link to a config file on our server. More specifically, a link to config.php, which exists outside of the document root of our website. Creating the link on Linux was simple, but with windows it was a bit more tricky. I found a good resource here that describes the types of symbolic links for windows http://www.maxi-pedia.com/mklink .

If I have the following directory structure C:\Program Files (x86)\Zend\Apache2\htdocs\application_root\public\ . I want the config.php file to exist within application_root, and I have index.php residing within the public directory. At the top of index.php, I’d write


The config.php file is not really at the root of the public directory where PHP would expect it to be, but rather one level deeper within application_root.

To setup the symbolic link, do the following

  1. Open a windows command prompt and change your directory to where you’d like the symbolic link to exist, in my case it is C:\Program Files (x86)\Zend\Apache2\htdocs\application_root\public\
  2. Run the following command mklink config.php “C:\Program Files (x86)\Zend\Apache2\htdocs\themlsonline\config.php”
  3. Open your apache conf file where the virtual host is specified and add “Options Indexes FollowSymLinks” within the node. More on this here http://www.maxi-pedia.com/FollowSymLinks.