When creating a website, occasionally there will be a need to hotlink to a file on the server. Hotlinking (or direct linking) is when a link uses the url to link, as apposed to linking to the directory relative to the file. An example of this is show in the following:

Link relative to the file location on the server:
<img src="/support/image.jpg" />

File Hotlinked or Directly linked to the server:
<img src="http://www.yourdomain.com/image.jpg" />

This is especially useful when using the Premium Web Builder. The Web Builder has the File download link; however, the problem with the File download link is that the file is accessible by everyone on the web. Hotlinking to the file allows the folder to be password protected, preventing people from accessing the file. This is common for those selling books in PDF format that only want people who paid for the book to download it. Lets learn how to directly link a file to the website.

Directly linking to a file on the server

  1. Log into cPanel
  2. link-to-file-server-1-file-managerGo to the File manager and navigate to the folder where the file will be uploaded.

    In this tutorial, a .jpg image will be uploaded to the myimage directory. If there is no directory to upload the file to, create the directory and upload the file there. Upload the file to the folder.

    For information on how to upload files through the cpanel File Manager click here


  3. link-to-file-server-2-index-ofNow that the file is uploaded, the file directory can be accessed. If visiting the directory in the browser With indexing set to default On, the directory will list the file on the page. See snapshot to the right.

    Visit the file through the browser by going to:

    http://yourdomainname.com/foldername/filename.file

    Where the "foldername" is replaced with the folder name on your server and the "filename.file" is replaced with the file that was uploaded to that directory.
  4. link-to-file-server-3-urlGet the url from the address bar of the browser. In this example the url will look like the following:

    http://yourdomainname.com/myimage/macaroni.jpg

    The url can be used in anchors, images, and other HTML tags where files can be linked to. Below are some examples of code that can be used.

    A download link or hyper link will use the following:
    <a href="http://yourdomainname.com/myimage/macaroni.jpg">hyper link</a>

    Hotlinking an image to your website uses the following:
    <img src="http://yourdomainname.com/myimage/macaroni.jpg" />

If you missed the last article, please see the tutorial on Anchor Links and How to Create Them. For more information about articles with a similar topic, please visit Inserting Links into a Website.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!