using symbolic link in htdocs (Solved)

Problems with the Windows version of XAMPP, questions, comments, and anything related.

using symbolic link in htdocs (Solved)

Postby Xyzzyx » 14. March 2013 09:34

I've got a situation where I'd like to be able to run things on xampp from several folders, without putting them all into \xampp\htdocs\. For example with a file structure like this:

Code: Select all
E:/dirA/dirB/somefile.php
E:/folder1/folder2/file2.php
E:/xampp/htdocs/dir0/file7.php


I'd rather not have to move somefile.php or file2.php into the \htdocs\ folder. I understand that there is such a thing as a 'symbolic link' that can be created using the `mkdir` command so that folder2 and dirB will behave as if they are in htdocs, and yet still allow dir0/file7.php to run as well.

Does this make any sense?
User avatar
Xyzzyx
 
Posts: 10
Joined: 14. March 2013 09:17
Operating System: Windows 7 Pro

Re: using symbolic link in htdocs

Postby Altrea » 14. March 2013 14:35

We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: using symbolic link in htdocs

Postby Xyzzyx » 14. March 2013 22:42

That looks like it might do what I need (btw, when I said `mkdir` above I actually meant `mklink`, but I see somewhere else it looks like it might be a linux-only thing. hmm). Not sure I understand alias completely though - if I create a folder in \htdocs\ called folder2, would I then use the following code:
Code: Select all
alias /folder2 /folder1/folder2

That is, does the first half correspond to the htdocs root, and the second half refer to the xampp root?

And then there's the question of where to put this command? Sorry I'm very new to all this! (I should mention the only mod_alias I could find in apache\modules\ had a .so extension eg. mod_alias.so and opens as complete garbage in my text editor)
User avatar
Xyzzyx
 
Posts: 10
Joined: 14. March 2013 09:17
Operating System: Windows 7 Pro

Re: using symbolic link in htdocs

Postby Altrea » 15. March 2013 05:33

Xyzzyx wrote:(btw, when I said `mkdir` above I actually meant `mklink`, but I see somewhere else it looks like it might be a linux-only thing. hmm).

Since Windows Vista you can create Symlinks in Windows too, but i wouldn't.
http://technet.microsoft.com/en-US/libr ... 94(v=ws.10).aspx

Xyzzyx wrote:Not sure I understand alias completely though - if I create a folder in \htdocs\ called folder2, would I then use the following code:
Code: Select all
alias /folder2 /folder1/folder2

If you create a folder in htdocs, you don't need any Alias, because that folder can be requested already (it is inside of the DocumentRoot).
Alias is helpful for directorys saved outside of your DocumentRoot.
You can see some example usage of Alias in your \xampp\apache\conf\extra\httpd-xampp.conf

Xyzzyx wrote:And then there's the question of where to put this command?

Somewhere inside a Apache configuration file. This could be your \xampp\apache\conf\httpd.conf or for example a configuration file created and Included into your httpd.conf yourself.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: using symbolic link in htdocs

Postby Xyzzyx » 16. March 2013 03:04

Oh, those examples in httpd-xampp.conf helped a lot! I see now that the command creates an invisible folder (comments in the conf file called it a webfolder) in the first half, pointing to the origin file in the second. Anyway, created a new file \xampp\apache\conf\extra\httpd-custom.conf with:
Code: Select all
Alias /dirB "/dirA/dirB"
   <Directory "/dirA/dirB">
        AllowOverride AuthConfig
        Require all granted
    </Directory>

Alias /folder2 "/folder1/folder2"
   <Directory "/folder1/folder2">
        AllowOverride AuthConfig
        Require all granted
    </Directory>


and in \xampp\apache\conf\httpd.conf I added a line:
Code: Select all
Include "conf/extra/httpd-custom.conf"


And it works! :D

Thank you so much Altrea for your help with this!
User avatar
Xyzzyx
 
Posts: 10
Joined: 14. March 2013 09:17
Operating System: Windows 7 Pro


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 119 guests