Like this way in Windows
mklink /D Virtual_Folder_Here Real_Folder_Here. I was unable make work
alias in Apache virtual sites in Windows so I made a virtual directory. Is this possible in Linux too?
The Linux way is to create a symbolic link:
ln -s /source_path /path/to/link_name This way you can either create links to files as well as to directories.
See https://technet.microsoft.com/en-us/library/cc753194.aspx for reference on
mklink where Microsft states that
/D is to be used to create symbolic links.
And http://unixhelp.ed.ac.uk/CGI/man-cgi?ln for the manual page of
See @Lambert for part of the answer. You will have to allow Apache to follow links, because if not used carefully, following symlinks can allow access to the rest of the filesystem, so Apache doesn't allow that by default. The option is
Options FollowSymLinks for a directory.
Another (probably a cleaner) way of doing this is bind-mounting. A symlinked directory is not a "true" directory in the filesystem (a soft link is essentially just a string that points to a different place) and the application knows that. But if you
mount --bind /origin/ /destination/, it's exactly the same as just having the contents of
/destination/ wasn't empty, its original contents are still under the mount, and umount reveals it.
Note that the mount must be done as root, and it has to be done after every boot (put it in
/etc/fstab just like the rest of the mounts). Typical use cases are a bit different. If you will use a lot of linking and rewire things frequently, use symlinks. If you need a steady, generally permanent rename/relocation of a directory, use mount.