-1

I'm just transferring all my files over from xampp's htdocs to my server and now I just need to add a favicon.

I have the icon saved as 'favicon1.ico' and it is a proper icon size 16x16, but I cant get it to work.

This is the code I have for it:

<html>
<title>Server Test</title>

<head>
<h1> Hello World </h1>


<link rel="shortcut icon" href="O:\Intranet\favicon1.ico"/>

</head>

<body>


</body>
</html> 

That is the correct location of the icon in the href so I dont see why this shouldn't work.

I've never added a favicon to a site before so that is where my main problem of not knowing exactly what it should look like lies.

dev_py_uk
  • 418
  • 1
  • 5
  • 20
  • 2
    It doesn't work because the `href` attribute value is supposed to be a **URL** not a Windows file path. – Quentin Oct 27 '15 at 10:25
  • In that case, is there a way of doing it using a file path? – dev_py_uk Oct 27 '15 at 10:26
  • 2
    If the server is located on your machine and if only you access the page, you can access the favicon with `file://O:/Intranet/favicon1.ico`. But it would be better if you refer to it with a relative path (like `./favicon1.ico`) – Reeno Oct 27 '15 at 10:26
  • 1
    Put your favicon into your web directory and use relative paths. There is one more error, h1 tag should be placed in body section. – Blady214 Oct 27 '15 at 10:34
  • Possible duplicate of [Adding a favicon to a static HTML page](http://stackoverflow.com/questions/9943771/adding-a-favicon-to-a-static-html-page) – dippas Oct 27 '15 at 10:36

2 Answers2

0

Your Favicon path uses a windows style File path as pointed out in the comments.

Ensure the following

  • favicon1.ico file is present in the package that you are transferring onto the server.
  • Ensure that the file is accessible over http (try using a browser to navigate to it). The path should be something like http://server:port/app-uri/favicon1.ico
  • After that as suggested in one of the comments use a relative path such as ./favicon1.ico in the HTML source.

Also I suggest reading up on the concept of favicon http://www.w3.org/2005/10/howto-favicon

vvs
  • 1,066
  • 8
  • 16
-1

Code below should work. Try this.

<link rel="icon" type="image/png" href="http://yoursite.com/favicon1.ico">

Notice that href points to the address of your icon depending where you put the icon.

claudios
  • 6,588
  • 8
  • 47
  • 90
  • I cant do it like this as it is a server on a LAN and the site doesn't have a domain – dev_py_uk Oct 27 '15 at 10:44
  • then point the address to your local site followed by where you put your icon. – claudios Oct 27 '15 at 10:50
  • @oggle0901 Use Relative paths. Relative path will work even if there is no domain as long as the favicon1.ico is there on the same server and publicly accessible using the server IP address e.g. if server is on local host then IP address is 127.0.0.1 and then the URL to the image (for purpose of accessing through browser) would be of the form `http://127.0.0.1:port_number/application_url/favicon1.ico` – vvs Oct 27 '15 at 14:58