Page 1 of 1

using symbolic link in htdocs (Solved)

PostPosted: 14. March 2013 09:34
by Xyzzyx
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?

Re: using symbolic link in htdocs

PostPosted: 14. March 2013 14:35
by Altrea

Re: using symbolic link in htdocs

PostPosted: 14. March 2013 22:42
by Xyzzyx
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)

Re: using symbolic link in htdocs

PostPosted: 15. March 2013 05:33
by Altrea
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.

Re: using symbolic link in htdocs

PostPosted: 16. March 2013 03:04
by Xyzzyx
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!