HostSEO Blog

Stories and News from IT Industry, Reviews & Tips | Technology Blog


How to create a symbolic link in cPanel

  • Category : cPanel Question
  • Posted on : Sep 01, 2020
  • Views : 904
  • By : HostSEO

Symlinks, short for symbolic links, are basically shortcuts to individual files or folders. One of the advantages of a symlink is that it can cross filesystems, as it references abstract filenames/directories and not physical locations.

There is a number of ways to create a symlink in cPanel:

1. You can create a symlink via SSH by running the following command:

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

2. It can also be created via a cronjob using the same command:





NOTE: Make sure that you delete the cronjob once the symlink has been created.

3. You can also create a symlink using the PHP function.

The example of the script can be found below:

<?php
$target = '/home/cPanelusername/public_html/index.html';
$shortcut = 'script.html';
symlink($target, $shortcut);
?>


Just run this PHP file in the browser and it will create symlink right away.


Example of the symlink usage

A symlink may be a perfect solution for a number of cases. In our example we will use a symlink in order to use images located in the main domain web root (/public_html/) for the addon domain website (/public_html/domain1.com):



Since the addon domain website does not have access to /public_html or any higher level directory, the only way to use images located in the /public_html/images folder is to create a symlink in the addon domain folder:

ln -s /home/ncexample/public_html/images/ /home/ncexample/public_html/domain1.com/images

As you can see, symlinks will help you to avoid duplicate content if you use the same files for multiple websites.

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.


That's it!

 

Subscribe Now

10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!

Archive Calendar

SatSunMonTueWedThuFri
 12345
6789101112
13141516171819
20212223242526
27282930 

Born in 2004 ... Trusted By Clients n' Experts

SEO Stars

They never made me feel silly for asking questions. Help me understand how to attract more people and improve my search engine ranking.

Read More

Emily Schneller Manager at Sabre Inc
SEO Stars

Took advantage of Hostseo's superb tech support and I must say, it is a very perfect one. It is very fast, servers reliability is incredible.

Read More

Leena Mäkinen Creative producer
SEO Stars

We're operating a worldwide network of servers with high quality standards requirements, we’ve choose hostseo to be our perfect partner.

Read More

Ziff Davis CEO at Mashable
SEO Stars

It’s very comfortable to know I can rely about all technical issues on Hostseo and mostly that my website and emails are safe and secured here.

Read More

Isaac H. Entrepreneur
SEO Stars

With hostseo as a hosting partner we are more flexible and save money due to the better packages with great pricing, free SEO n' free SSL too!

Read More

Madeline E. Internet Professional