Creating symbolic link in cPanel (Shared Servers)

There several ways to create a symlink on our Shared Cpanel servers.

Create a symlink via SSH

You can create a symlink via SSH. To make sure your plan supports it and to be enabled for your user, please contact our Technical Department.

Once enabled you can create symlinks using the following command as an example:

ln -s /path/to/target /path/to/shortcut

Create a symlink using PHP function

You can also create a symlink using the PHP function. 

  1. To do that login via the File Manager and click on File.

  1. Name your php-script (example: symlink.php) and click Create New File.

  1. Right-click on the file and choose Edit.

  1. Add the following code below:

php $target = '/home/cPanelusername/public\_html/index.html'; $shortcut = 'script.html'; symlink($target, $shortcut); ?

NOTE: $target and $shorcut are variable that you need to change as per your requirements.

  1. Click Save Changes and run this PHP file in the browser and it will create symlink right away.

NOTE: Creating symlinks to root directories of other websites may cause serious security breaches, that's why we highly recommend using symlinks only for those folders that do not expose any config or system files, as, if acquired, such files may be used for hacking or other malicious activity.