bhttoan
bhttoan

Reputation: 2736

Creating a symlink in WAMP server on Windows

I am working on a downloaded version of an application and am getting multiple errors due to:

( ! ) Warning: include(/home/USERNAME/public_html/dir/includes/functions.php): failed to open stream: No such file or directory in C:\wamp\www\dir\includes\db_connection.php on line 6

I understand what the error is but I don't want to have to manually change all these includes in the code mainly as doing so means when I update my ive site they will then be wrong.

Is there a way using either WAMP or Windows of creating something like a symlink to tell WAMP that anything in /home/USERNAME/public_html/dir should be served from C:\wamp\www\dir?

I found an option in WAMP for creating an alias but I am not sure if this is the right thing to use?

Upvotes: 4

Views: 3342

Answers (1)

Valentine Shi
Valentine Shi

Reputation: 7800

There is an answer on SO here.

This link https://www.sevenforums.com/tutorials/278262-mklink-create-use-links-windows.html would serve well too (from the answer above).

Basically you have to use mklink Windows command from command prompt (the latter must be run as administrator).

Now. Assume you have WAMP installed and virtual host named mysite.local is created and pointinig to the physical d:\mysite folder. You want now the files in the folder f:\otherfolder\realfolder to be accessible via mysite.local/otherfolder/somefile.ext kind of URL.

For this you have to create the symbolic link named otherfolder in d:\mysite that will point to f:\otherfolder\realfolder. You have to execute:

mklink /D d:\myfolder\otherfolder f:\otherfolder\realfolder

from Windows command prompt. The link otherfolder is created in d:\myfolder and you can access files via an URL as mentioned above.

Upvotes: 1

Related Questions