How to create a symbolic link in cPanel
Symbolic links, short for symbolic links, are basically shortcuts to individual files or folders. One of the advantages of a symbolic link 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 symbolic link in cPanel:
1. You can create a symbolic link 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 symbolic link has been created.
3. You can also create a symbolic link using the PHP function.
The example of the script can be found below:
$target = '/home/cPanelusername/public_html/index.html';
$shortcut = 'script.html';
symboliclink($target, $shortcut);
?>
Just run this PHP file in the browser and it will create symbolic link right away.
Example of the symbolic link usage
A symbolic link may be a perfect solution for a number of cases. In our example we will use a symbolic link 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 symbolic link in the addon domain folder:
ln -s /home/ncexample/public_html/images/ /home/ncexample/public_html/domain1.com/images
As you can see, symbolic links will help you to avoid duplicate content if you use the same files for multiple websites.
NOTE: Creating symbolic links to root directories of other websites may cause serious security breaches, that's why we highly recommend using symbolic links 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!
"Our guide will help you understand the underlying principles of WordPress optimization"
Rasalina Willamson
Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae
Share this Post
Trusted By
900+
Client World wide
24x7x365
Professional Technical Support
Providing Cloud
Services
Since 2008
Network Uptime
99.9%
Server Uptime