_       _       
  (_) ___ | |_ ____
  | |/ _ \| __|_  /
  | | (_) | |_ / / 
 _/ |\___/ \__/___|

Uploading directories with symbolic links to web server


This is a note on how to create a zipped folder including relative symbolic links (symlinks) that can be uploaded to a web server and unpacked there with the symlinks still working. I tested this on Hetzner web hosting, where the web FTP interface provides an option to zip and unzip files. The same interface does not provide any way of creating symlinks, so this zip method is a useful workaround.


In your home folder, create a directory with some files:

cd ~
mkdir abc
cd abc
echo One > 1.txt
echo Two > 2.txt
echo Three > 3.txt

Then create a sub-directory containing symlinks to the files in the parent directory. Note that these are relative symlinks, so the target they need to link to is specified as a relative path (relative to the location of the symlink).

mkdir xyz
cd xyz
ln -s ../1.txt 1.txt
ln -s ../2.txt 2.txt
ln -s ../3.txt 3.txt

Create a zip file of the parent folder, including the "r" option to recursively include the contents of the directory, and the "y" option to preserve symlinks rather than archiving a copy of the file.

cd ~
zip -ry files.zip abc/

Upload the zip file to the web server (e.g. public_html directory) and unzip it.